Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP.Net File Upload BIG files?

Status
Not open for further replies.

markdmac

MIS
Dec 20, 2003
12,340
US
Hi Everyone,

I'm looking for a free solution to upload large files via a web interface. Documents could be as large as 1GB.

I have some working code that will upload files:
Code:
<%@ Page Language="VB" %>
<script runat="server">

    ' Insert page code here
    '
    Sub Upload_Click(Sender as Object, e as EventArgs)
    Dim FileName
    Dim FileContent
    Dim FileSize
    Dim Span1
    Dim Span2

      ' Display properties of the uploaded file
      FileName.InnerHtml = MyFile.PostedFile.FileName
      FileContent.InnerHtml = MyFile.PostedFile.ContentType
      FileSize.InnerHtml = MyFile.PostedFile.ContentLength
      UploadDetails.visible = True

      'Grab the file name from its fully qualified path at client
      Dim strFileName as string = MyFile.PostedFile.FileName

      ' only the attched file name not its path
      Dim c as string = System.IO.Path.GetFileName(strFileName)

      'Save uploaded file to server at C:\ServerFolder\
      Try
        MyFile.PostedFile.SaveAs("C:\Documents and Settings\mmaclachlan\My Documents\webmatrix\imcraft\Files\" + c)
        Span1.InnerHtml = "Your File Uploaded Sucessfully at server as: " & _
                          "C:\Documents and Settings\mmaclachlan\My Documents\webmatrix\imcraft\Files\" & c
      Catch Exp as exception
        Span1.InnerHtml = "An Error occured. Please check the attached  file"
        UploadDetails.visible = false
        Span2.visible=false
      End Try
    End Sub

</script>
<html>
<head>
</head>
<body>
    <%-- The Web Form with the EncType property set to Multipart/Form-Data --%>
    <form method="post" enctype="multipart/form-data" runat="Server">
        <%-- The File upload Html control --%>Choose Your File To Upload
        <br />
        <input id="MyFile" type="file" runat="Server" />
        <br />
        <%-- A button - when clicked the form is submitted and the
            Upload_Click event handler is fired... --%>
        <input type="submit" value="Upload" runat="Server" onserverclick="Upload_Click" />
        ...
    </form>
</body>
</html>

The above works great for small files, but anything larger than 1MB seems to fail. I need to be able to upload some large images used for high definition printing.

Any help would be greatly appreciated.

I hope you find this post helpful.

Regards,

Mark
 
in the web.config file change the maxRequestLength size to 1GB, the example that i have given allows upto 20MB.

<system.web>
<httpRuntime maxRequestLength="20480"/>
</system.web>


Known is handfull, Unknown is worldfull
 
Thank you vbkris, I will give that a try this afternoon. I don't currently have a web.config file, should there be any other text in there? Sorry about being so naive, I am new to ASP.Net.

Another item I need to tackle is being able to select multiple attachments. Is there a way to do that by modifying the code I have above that you know of?

I hope you find this post helpful.

Regards,

Mark
 
<configuraion>
<system.web>
<httpRuntime maxRequestLength="20480"/>
</system.web>
</configuration>

try googling for more info on it:


>>Another item I need to tackle is being able to select multiple attachments

just increase the maxRequestLength by so many fields...

Known is handfull, Unknown is worldfull
 
Thanks again vbkris,

Sorry if I am being dense here. But doesn't the maxrequestlength just specify the size of the attachment? What I am hoping to do is allow the user to select multiple files at once. The current control only seems to allow one file to be selected for upload.

I appreciate your help.

Mark
 
u have to provide more HttpInput fields, like Yahoo does...

Known is handfull, Unknown is worldfull
 
Thank you.

I hope you find this post helpful.

Regards,

Mark
 
I did some rather extensive testing this afternoon. I was able to get the file size up to 62MB. I was testing in 10MB increments. At 72MB this will still not complete, the screen continues to reload but never finishes and the file never gets uploaded.

Anyone know if there a hard coded limit for file sizes in ASP.Net?

I hope you find this post helpful.

Regards,

Mark
 
This might be a solution


Overview

SlickUpload is an ASP.NET HttpModule that provides scalable upload handling for ASP.NET applications. ASP.NET doesn't have any capacity to stream requests to disk, and thus will load an entire upload into memory before processing it. This can cause scalability problems, as well as opening up a possible vulnerability to a denial of service (DOS) attack. SlickUpload fixes these problems by intercepting the request before the ASP.NET page processing engine gets it, and streaming it in chunks directly to disk. This eliminates the problem of loading the request into memory. SlickUpload also provides rich progress and status information during the upload process, allowing an application to display upload status to the user in real time.
 
Thanks stsuing I have just downloaded it and will check it out. Will provide feedback ASAP.

I hope you find this post helpful.

Regards,

Mark
 
stsuing, have byu chance used the clickupload succesffully? I can't seem to get it to work just using their sample code to start with.

Here is my configuration.

1. Existing web site on Windows 2000 Server.
2. Created directory call fileupload under main site.
3. Created a bin directory under fileupload and moved DLL files to this directory.
4. Copied Web.Confic file from sample code to root of main site. Modified file save path to the folder I want.
5. Created Application for fileupload directory. Set security to allow both scripts and executables.
6. Copied sample code to fileupload directory.
7. Set default page to be default.aspx.

When I try to visit the site I get a runtime error with the suggestion to add the following to the webconfig file

<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>

I added the line <customErrors mode="Off"/>
in the system.web section of the web.config file but still get the same message.

Any ideas of what I am doing wrong? the write up on this sounds perfect so I would relly like to get it working.

Thanks.

I hope you find this post helpful.

Regards,

Mark
 
This is probably the web.config file in the fileupload directory directory. Change that one so you can see the error. I did the simple example and it worked ok.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top