HTML: Form upload, only allow PNG, GIF & JPG
I have a form file upload. When the users goes to upload an image, it displays all files on their computer. How 开发者_如何学运维can I make the HTML upload dialog window to only display JPG, GIF and PNGs?
Just add accept to input with file types. This will filter the list of displayed files, but not create ban on download other files. This is convenient, because it is simple.
The file upload dialog in the web browser is outside of your control. You could create a Java applet for uploading images, like Facebook did.
As this hasn't been answered yet; add the following code to your file input
accept="image/x-png,image/gif,image/jpeg"
精彩评论