restrict file upload size

Discussions

Web tier: servlets, JSP, Web frameworks: restrict file upload size

  1. restrict file upload size (3 messages)

    Hello all,

    In JSP / HTML, I want to restrict the size of file being uploaded.

    <input type="file" name="myfile"/>

    If the size of file more than a specific size say 5MB, i want to give mesage to the user. I don't want to wait till the file gets uploaded to server and then validate the file size. I need client side validation. Can it be done using scripting language or any other way?

    I need a solution for this in Internet Explorer. I got solution using ActiveX control:
    var myFSO = new ActiveXObject("Scripting.FileSystemObject");
    var filepath = document.getElementById('myfile').value;
    var thefile = myFSO.getFile(filepath);
    var sizeInBytes = thefile.size;

    But ActiveX controls are not allowed in our application. Is there any alternative way for this?

    PLease suggest the possible ways.. Thanks in advance!!

    ----
    Poli reddy

    Threaded Messages (3)

  2. restrict file upload size[ Go to top ]

    Is Applet a solution for this??

  3. restrict file upload size[ Go to top ]

    I've used applets and it worked.

    jFileUpload solved this problem:
    http://www.jfileupload.com/products/jfileupload/ => download link
    http://jupload.sourceforge.net/howto-customization.html => documentation
    * http://www.jfileupload.com/products/jfileupload/documentation/configuration_http.html => config params

    maxsize- This parameter identify the maximum size of the uploaded file. It prevents the user to upload too big files.

     

  4. restrict file upload size[ Go to top ]

    Upload taglib lets you restrict the size: http://www.servletsuite.com/servlets/uptag.htm