Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    May 2009
    Location
    North west England
    Posts
    17
    Thanks
    1
    Thanked 0 Times in 0 Posts

    File Uploading problem

    I have a site under development that allows a punter to upload a single file to the web server. I use ASP.NET. The html fragment that allows the punter to select the file to upload is the well known
    <input type=file id=file1 name=file1 runat="server" />
    which enables the punter to select a file and populate a textbox with a path such as \Test documents\TestdoxA

    The problem is that if this file is bigger than about 4 Mb, the upload process goes wrong and the result can look a mess to the punter.

    At the point where \Test documents\TestdoxA appears in the textbox, (and before the punter presses the upload button) I would like to intervene and find the length of the file in bytes. Then, if it is too long, bring up a window to warn the guy off.

    Can I do this with Javascript (or anyhow else, for that matter) ? If so, could someone point me at a bit of code that I could make a start with, please ?

  • #2
    GŁtkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    There is no sure fire cross browser way to do that. What you should do is inform the user that there is a file size limit and change your server side code, so that it does not present the user with "a mess", if she decides to upload files exceeding the limit, but with a user friendly message informing her about her mistake.

  • Users who have thanked venegal for this post:

    dcwm (05-24-2009)


  •  

    Posting Permissions

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