Skip to content

JS input 文件上传格式限制

Published: at 05:34 PMSuggest Changes

上传文件时对文件的格式限制

图片

<input
  ref="imageFileUpload"
  type="file"
  hidden
  @change="onImageFileChanged"
  accept="image/png, image/gif, image/jpeg, image/bmp, image/x-icon"
  style="display: none"
/>

视频

<input
  ref="videoFileUpload"
  type="file"
  hidden
  @change="onVideoFileChanged"
  accept="video/mp4,video/x-m4v,video/*"
  style="display: none"
/>

Previous Post
JS ref 获取 DOM 元素
Next Post
JS Axios 文件上传