Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void UploadFile(string filename)
- {
- try
- {
- PeopleMatrixService peopleMetrixService = new PeopleMatrixService();
- String strFile = System.IO.Path.GetFileName(filename);
- // TestUploader.Uploader.FileUploader srv = new TestUploader.Uploader.FileUploader();
- FileInfo fInfo = new FileInfo(filename);
- long numBytes = fInfo.Length;
- double dLen = Convert.ToDouble(fInfo.Length / 10000000);
- if (dLen < 8)
- {
- FileStream fStream = new FileStream(filename, FileMode.Open, FileAccess.Read);
- BinaryReader br = new BinaryReader(fStream);
- byte[] data = br.ReadBytes((int)numBytes);
- br.Close();
- string sTmp = peopleMetrixService.UploadFile(data, strFile);
- fStream.Close();
- fStream.Dispose();
- MessageBox.Show("File Upload Status: " + sTmp, "File Upload");
- }
- else
- {
- MessageBox.Show("The file selected exceeds the size limit for uploads.", "File Size");
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message.ToString(), "Upload Error");
- }
- }
- [WebMethod]
- public string UploadFile(byte[] f, string fileName)
- {
- try
- {
- MemoryStream ms = new MemoryStream(f);
- FileStream fs = new FileStream(System.Web.Hosting.HostingEnvironment.MapPath("~/Response Attachments/") + fileName, FileMode.Create);
- //FileStream fs = new FileStream(Server.MapPath("~/Response Attachments/") + fileName, FileMode.Create);
- ms.WriteTo(fs);
- ms.Close();
- fs.Close();
- fs.Dispose();
- return "OK";
- }
- catch (Exception ex)
- {
- return ex.Message.ToString();
- }
- }
- <configuration>
- <system.web>
- <httpRuntime executionTimeout="300" maxRequestLength="20480" />
- </system.web>
- </configuration>
- <system.web>
- <httpRuntime executionTimeout="360" maxRequestLength="100000" />
- C:WindowsSystem32inetsrv>appcmd set config "[IISWebsitename]" -section:requestFiltering -requestLimits.maxAllowedContentLength:100000000 -commitpath:apphost
Add Comment
Please, Sign In to add comment