How to check file input size with jQuery?

前端 未结 8 2419
渐次进展
渐次进展 2020-11-22 09:21

I have a form with file upload capabilities and I would like to be able to have some nice client side error reporting if the file the user is trying to upload is too big, is

8条回答
  •  北恋
    北恋 (楼主)
    2020-11-22 09:47

    This code:

    $("#yourFileInput")[0].files[0].size;
    

    Returns the file size for an form input.

    On FF 3.6 and later this code should be:

    $("#yourFileInput")[0].files[0].fileSize;
    

提交回复
热议问题