How to validate a file upload field using Javascript/jquery

前端 未结 6 963
伪装坚强ぢ
伪装坚强ぢ 2021-02-07 03:54

How can I validate if the user has selected a file to upload?

Edit: bumped

6条回答
  •  臣服心动
    2021-02-07 04:27

    Building on Ravinders solution, this code stops the form being submitted. It might be wise to check the extension at the server-side too. So you don't get hackers uploading anything they want.

    
    
    

提交回复
热议问题