How to check input file is empty, and also display an alert if png format is selected using jquery

后端 未结 4 1482
谎友^
谎友^ 2021-02-07 11:23

I have got an input file upload , need to check which file is uploaded / if no file is selected by the client using jquery.



        
4条回答
  •  隐瞒了意图╮
    2021-02-07 11:30

    Testing for...

    $('#file1')[0].files.length == 0
    

    ...is working for me in Chrome. The jQuery is actually not even necessary as the raw HTML element (returned by the [0] on the jQuery object) gives access to the files list.

提交回复
热议问题