设置服务器在 HTML 中接受的文件类型

htmlfront end technologyweb development更新于 2025/8/14 11:56:17

使用 accept  属性设置服务器在 HTML 中接受的文件类型。该属性仅用于 <input type = "file>。

示例

您可以尝试运行以下代码来使用 accept 属性 −

<!DOCTYPE html>
<html>
   <head>
      <title>File Upload Box</title>
   </head>
   <body>
      <form>
         <input type = "file" name = "fileupload" accept = "image/*" />
      </form>
   </body>
</html>

相关文章


有用资源