commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Spencer Elliott <spen...@solution400.com>
Subject Re: FileUpload Streaming API checking file size
Date Wed, 14 Mar 2007 19:13:40 GMT
Hi,
I used the following to check the size. It is not exact but it's better 
than nothing...

if ( (sz = request.getContentLength()) > (maxFileSz)  ) {
    resp.getWriter().write("<span style='color:red;'>Maximum transfer 
size of: " + maxFileSz + " bytes exceeded!</span>");
    return;
}

Spencer


Spencer Elliott wrote:
> Hi,
> I am using the common.fileupload 1.2 streaming API to upload files 
> using AJAX (YAHOO) and servlets.
>
> I have used setFileSizeMax to limit file upload size but find it 
> unacceptable because the exception is not triggered until 
> setFileSizeMax bytes are read/written.
>
> I would like to check the file sizes before the upload begins.  Is 
> there a way to access fileSize property?
>
> I have also attempted to use the progressListener and this gives me 
> the file size sooner but I am unsure what the proper procedure is to 
> terminate the stream from the listener?
>
> Thanks,
>
> Spencer
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
> __________ NOD32 2093 (20070303) Information __________
>
> This message was checked by NOD32 antivirus system.
> http://www.eset.com
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message