Recommended way to check file size on upload

前端 未结 10 780
南笙
南笙 2021-02-04 10:33

I am working on a web application which supports file uploading. I am already familiar checking the size in server side, but i wanted to check the file size in a client side.

10条回答
  •  既然无缘
    2021-02-04 10:59

    It is possible to determine the size of the file that is on uploading even before the uploaded file has been transfered completely. Even when using Internet Explorer. By using the HTTP's content-length header!
    In java world:
    First of all the if you handle the request that arrive to the server in the first servlet/filter/controller before any previous thread mass with it, you'll be albe to get the total file size in the content-length header (request.getContentLength()).

    second- have a look in an ajax implementation that prove that it is possible: http://www.ajaxfilebrowser.com/

提交回复
热议问题