简体   繁体   中英

Java file upload size check

I am using jsp/servlet for file upload,

i am able to upload a file but want to limit the size of files that can be uploaded. Is there any way to check the size of file without uploading it.. (on server side)

You can set setSizeThreshold using commons-fileupload

Note: * You can't determine the file size without streaming it up directly to server *

Is there any way to check the size of file without uploading it .. (on server side)

No, the server has no way to access the client's file system.

Not even Client-Side JavaScript may access the file system, for security reasons, so the only way would be to run some signed software with special privileges on the client (Signed Java Applet etc.). This would however require the client to allow the software to run.

The answer that makes the most sense is hence org.life.java's answer to limit the upload size from the server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM