I need to upload large files of at least 1GB
file size.
I am using ASP.Net
, C#
and IIS 5.1
as my development platform.
I am using:
HIF.PostedFile.InputStream.Read(fileBytes,0,HIF.PostedFile.ContentLength)
before using:
File.WriteAllBytes(filePath, fileByteArray)
(doesnt go here but gives System.OutOfMemoryException
exception)
Currently I have set the httpRuntime
to:
executionTimeout="999999" maxRequestLength="2097151"(thats 2GB!) useFullyQualifiedRedirectUrl="true" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="5000" enableVersionHeader="true" requestLengthDiskThreshold="8192"
Also i have set maxAllowedContentLength="**2097151**"
(guess its only for IIS7)
I have changed IIS
connection timeout to 999,999 secs too.
I am unable to upload files of even 4578KB
(Ajaz-Uploader.zip)
We have an app that occasionally needs to upload 1 and 2 GB files, so has been running into this as well. After much research, my conclusion is that we need to implement the previously mentioned NeatUpload, or something like it.
Also, be aware that
is measured in bytes, while
is measured in kilobytes. So your values should look more like this:
Check this blog entry about large file uploads. It also has a few links to some discussion forums that can shed some light on this as well. The suggestion is to use custom HttpHandler for that or custom Flash/Silverlight control.
I know it is an old question, but still unanswered.
So this is what you have to do:
In you web.config file, add this in :
and this under
You see in the comment how this works. In one you need to have the sie in bytes and in the other one in kilobytes. Hope that helps.
Setting maxRequestLength should be enough for uploading files larger than 4mb, which is the default limit for HTTP request size. Please make extra sure that nothing is overriding your config file.
Alternatively you can check the async upload provided by Telerik, which uploads files by 2mb chunks and effectively can bypass the ASP.NET request size limitation.
I think you should use Response.TransmitFile, this method does not load in web server memory the file, it streams the file without using web server resources.
I googled and found - NeatUpload
Another solution would be to read the bytes on the client and send it to the server, the server saves the file. Example
Server: in Namespace - Uploader, class - Upload
Client: