NoteZ_技术博客 NoteZ_技术博客
🏠 首页
  • 📚 Web技术
  • 📋 Npm笔记
  • 📑 Markdown
  • 📄 Git笔记
  • 📝 Nginx文档
  • 📓 Linux文档
  • 📖 技术文档
  • 📜 其他文档
  • 🧊 NodeJs
  • 🎡 Express
  • 🔥 Rust
  • 🎉 Koa2
  • 🍃 MongoDB
  • 🐬 MySql
  • 🥦 Oracle
  • 🍁 Python
  • 🍄 JavaScript
  • 🌰 CSS
  • 🧄 HTML
  • 🥑 Canvas
  • 🌽 Nuxt
  • 🍆 React
  • 🥜 Vue
  • 🧅 TypeScript
  • 🌶️ AI
  • 📘 分类
  • 📗 标签
  • 📙 归档
⚜️ 在线编辑 (opens new window)
  • 📁 站点收藏
  • 📦 前端组件库
  • 📊 数据可视化
  • 🌈 开源插件
  • 🎗️ 关于我
  • 🔗 友情链接
GitHub (opens new window)

NoteZ_技术博客

前端界的小学生
🏠 首页
  • 📚 Web技术
  • 📋 Npm笔记
  • 📑 Markdown
  • 📄 Git笔记
  • 📝 Nginx文档
  • 📓 Linux文档
  • 📖 技术文档
  • 📜 其他文档
  • 🧊 NodeJs
  • 🎡 Express
  • 🔥 Rust
  • 🎉 Koa2
  • 🍃 MongoDB
  • 🐬 MySql
  • 🥦 Oracle
  • 🍁 Python
  • 🍄 JavaScript
  • 🌰 CSS
  • 🧄 HTML
  • 🥑 Canvas
  • 🌽 Nuxt
  • 🍆 React
  • 🥜 Vue
  • 🧅 TypeScript
  • 🌶️ AI
  • 📘 分类
  • 📗 标签
  • 📙 归档
⚜️ 在线编辑 (opens new window)
  • 📁 站点收藏
  • 📦 前端组件库
  • 📊 数据可视化
  • 🌈 开源插件
  • 🎗️ 关于我
  • 🔗 友情链接
GitHub (opens new window)
  • JavaScript笔记

  • CSS笔记

  • HTML笔记

    • HTML字符串中匹配关键词高亮
    • iframe加载完成事件
    • PC 端使用 rem 适配屏幕尺寸大小(自适应方案)
    • pc端网页屏幕自适应适配方案(rem)
    • 关于 HTML 中的 input accept属性详解(文件上传)
    • 前端如何使用a标签下载文件
    • 常用meta整理
    • 详解 input 中的 accept 属性(文件上传)
  • Canvas笔记

  • Nuxt笔记

  • React笔记

  • Vue笔记

  • TypeScript笔记

  • AI相关笔记

  • 开发文档
  • HTML笔记
NoteZ
2023-12-23

详解 input 中的 accept 属性(文件上传)

input accept属性是用来限制上传的文件格式

 <input type="file" id="file" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" /><a href="javascript:selectFile()">加载本地excel文件</a>
1
function selectFile() {
   document.getElementById('file').click();
}
1
2
3

1.上传.csv格式

<input text="file" accept=".csv" />
1

2.上传.xls格式

<input text="file"  accept="application/vnd.ms-excel"/>
1

3.上传.xslx格式

<input text="fiel" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"/>
1

4.上传.png/.jpg/etc格式

<input type="file" accept="text/plain" />
1

5.上传图片格式

<input type="file" accept="image/*" />
1

6.上传.htm,.html格式

<input type="file" accept="text/html" />
1

7.上传video(.avi, .mpg, .mpeg, .mp4)格式

<input type="file" accept="video/*" />
1

8.上传audio(.mp3, .wav, etc)格式

<input type="file" accept="audio/*" />
1

9.上传.pdf格式

<input type="file" accept=".pdf" />
1

10.如果限制两种文件格式,同时限制

<input type="file" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel">
1
#HTML
上次更新: 2024/01/30, 00:35:17
常用meta整理
Canvas 基础笔记总结

← 常用meta整理 Canvas 基础笔记总结→

最近更新
01
Gitea数据备份与还原
03-10
02
Linux 中使用 rsync 同步文件目录教程
03-10
03
Linux 使用 rsync 互相传输同步文件的简单步骤
03-08
更多文章>
Theme by Vdoing | Copyright © 2019-2025 NoteZ,All rights reserved | 冀ICP备2021027292号-1
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式