Receiving posted file
-
I'm using
System.Net.WebClient
to upload files to my server. The client is a windows application, not a web app. I've attempted to POST to my aspx page using two methods in the WebClient class. The firstUploadFileAsync
works well, unless I POST a file larger than 4 mb. Here is the code in the aspx page to receive the posted file:foreach (string f in Request.Files.AllKeys) { HttpPostedFile file = Request.Files[f]; file.SaveAs("c:\\inetpub\\test\\UploadedFiles\\" + file.FileName); }
So I thought I would try usingUploadDataAsynch
instead to see if there is a similar issue with the size of the POST. My problem is that I don't know exactly how to receive the data in the POST on the web page and write it to file on the server when using UploadDataAsynch. I'm sure it is very simple code but it's eluding me at the moment. If any one has a suggestion, I'd appreciate it.
"Half this game is ninety percent mental." - Yogi Berra If you can read thank a teacher, if you can read in English, thank a Marine.
-
I'm using
System.Net.WebClient
to upload files to my server. The client is a windows application, not a web app. I've attempted to POST to my aspx page using two methods in the WebClient class. The firstUploadFileAsync
works well, unless I POST a file larger than 4 mb. Here is the code in the aspx page to receive the posted file:foreach (string f in Request.Files.AllKeys) { HttpPostedFile file = Request.Files[f]; file.SaveAs("c:\\inetpub\\test\\UploadedFiles\\" + file.FileName); }
So I thought I would try usingUploadDataAsynch
instead to see if there is a similar issue with the size of the POST. My problem is that I don't know exactly how to receive the data in the POST on the web page and write it to file on the server when using UploadDataAsynch. I'm sure it is very simple code but it's eluding me at the moment. If any one has a suggestion, I'd appreciate it.
"Half this game is ninety percent mental." - Yogi Berra If you can read thank a teacher, if you can read in English, thank a Marine.
Ah problem solved. I can upload larger files with UploadFileAsych, I simply needed to override the default setting of 4mb in the system.web section of my web.config by setting this:
<httpRuntime maxRequestLength="10240" >
Here is the kb if anyone is interested.: http://support.microsoft.com/kb/295626[^]
"Half this game is ninety percent mental." - Yogi Berra If you can read thank a teacher, if you can read in English, thank a Marine.