input file limit the format when uploading images

(1) Use the accept attribute in the file upload. The input field in this example can accept both GIF and JPEG images:

<form>
  <input type="file" name="pic" id="pic" accept="image/gif, image/jpeg" />
</form>

Without limiting the format of the image, it can be written as:

accept="image/*"

 

 

(2) Definition and usage

The accept attribute can only be used with <input type="file">. It specifies the file types that can be submitted via file upload.

Tip: Avoid using this property. The file upload should be validated on the server side.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326016122&siteId=291194637