开发者

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.开发者_Python百科. (on server side)


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.


You can set setSizeThreshold using commons-fileupload

  • Here is example of the same

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜