FileUpload web service works on local machine but not on Web server... Help?


i'm using following web service:

public class fileservice : system.web.services.webservice      {          private string filepath;            public fileservice()          {              filepath = httpcontext.current.server.mappath("files");          }            [webmethod]          public string helloworld()          {              return "hello world";          }            [webmethod]          public string uploadfiles(string filename, byte[] byfile, string strfileno)          {              try              {                  if (byfile.length > 0)                  {                      //make sure filename has no path information.                      string file = path.combine(filepath, path.getfilename(filename));                        //string strfilepath = httpcontext.current.server.mappath("//10.0.2.30/files/" + filename);                      using (filestream fs = new filestream(file, filemode.create))                      {                          fs.write(byfile, 0, (int)byfile.length);                          fs.close();                      }                      return strfileno;                  }                  else                  {                      return "";                  }              }              catch (exception err)              {                  return err.message;              }          }      }


and when run on local machine works fine, should. however, when run on web server, keep getting inner exception error. i've been playing permissions , have added folder "files" share folder on web server , given group "everyone" access write folder, yet still won't write web server.

what doing wrong? :s

i think problem due permissions only.

better try following code block creating file stream.

 using (filestream fs = new filestream(file, filemode.create, fileaccess.readwrite))              {                  fs.write(byfile, 0, (int)byfile.length);                  fs.close();              }




Silverlight  >  Programming Silverlight with .NET – General



Comments

Popular posts from this blog

Conditional formatting a graph vertical axis in SSRS 2012 charts

Register with Power BI failed

SQL server replication error Cannot find the dbo or user defined function........