Results 1 to 5 of 5

Thread: File Upload - Large Files?

  1. #1
    Join Date
    Apr 2007
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question File Upload - Large Files?

    Hi,

    When attempting to upload a file to my server (using the <input type="file" /> tag) I get a "The connection was reset" error in firefox.

    However, this only happens when I attempt to upload larger files, roughly greater than 2 mb.

    Is this a server limitation?

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    It could be a server limit, or it could be something else in the form or server-side script you use to upload the files. If you could post the rest of the code for your form as well as the server-side script, we could probably give you a better answer.

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Apr 2007
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Form tag:
    <form method="post" runat="server" enctype="multipart/form-data">

    File input:
    <input type="file" size="34" id="tbUpload" runat="server" />

    C# server side file uploader
    Code:
    public static void UploadFile(HttpPostedFile file, string type, string destination, bool canOverwrite)
        {
            HttpPostedFile uFile = file;
    
            if (uFile == null || uFile.ContentLength == 0 || uFile.FileName == "") throw new Exception("No file has been selected!");
    
            if (type != "")
                if (uFile.ContentType != type)
                    throw new ArgumentException("Type does not match! Allowed: " + uFile.ContentType);
    
            int len = uFile.ContentLength;
            byte[] data = new byte[len];
    
            uFile.InputStream.Read(data, 0, len);
    
            if (File.Exists(destination))
            {
                if (canOverwrite) File.Delete(destination);
                else throw new Exception("File already exists!");
            }
    
            FileStream newFile = File.Create(destination);
            newFile.Write(data, 0, data.Length);
            newFile.Close();
        }

  4. #4
    Join Date
    Apr 2007
    Location
    Down the road from the store
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    You might be timing out. You said it's when you try to upload files larger than 2MB, which obviously takes longer than when uploading smaller files. It's just a suggestion, but do you have a server or session timeout set?

  5. #5
    Join Date
    Apr 2007
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    After uploading my website to my host my uploading worked fine, so I guess it was just a local problem.

    Thanks for the help anyways =)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •