设置input上传类型
来源:互联网 发布:淘宝最高等级店铺 编辑:程序博客网 时间:2024/05/17 02:25
一、第一个也是最常用的,设置只允许上传图片文件,我写好了简洁的代码,样式大家可以自己设。重要的就是后面的accept="image/*";
代码如下:
<div style="margin-left:200px;margin-top:100px;">
//只允许上传图片
<input type="text" id="text1">
<input type="file" id="file" accept="image/*">
</div>
可以看到清晰的看到那边显示只能上传图片文件
二、设置只允许上传视频文件,没有第一个用的多,但也会用到。
代码如下:
<div style="margin-left:200px;margin-top:400px;">
//只允许上传视频文件
<input type="text" id="text1">
<input type="file" id="file" accept="video/*">
</div>
三、设置只允许上传音频文件,这个是上传常见的音频文件。像一些mp3,wav
代码如下:
<div style="margin-left:200px;margin-top:400px;">
//只允许上传音频文件
<input type="text" id="text1">
<input type="file" id="file" accept="audio/*">
</div>
四、这个是单独挑出来的,只允许上传wav文件。这个用的比较多,一般上传铃声的时候用到。
代码如下:
<div style="margin-left:200px;margin-top:400px;">
//只允许上传wav文件
<input type="text" id="text1">
<input type="file" id="file" accept=".wav">
</div>
五、还有一个就是上传excel文件,反正我现在没有用到,你们谁需要的get一下。
代码如下:
<div style="margin-left:200px;margin-top:400px;">
//只允许上传EXCEL文件
<input type="text" id="text1">
<input type="file" id="file" accept="application/vnd.ms-excel "> </div>
六、最后一个本来不想放上来的,我阅历有限,目前没有看到哪个网站要上传pdf,估计也就是文库类网站了。
代码如下:
<div style="margin-left:200px;margin-top:400px;">
//只允许上传pdf文件
<input type="text" id="text1">
<input type="file" id="file" accept=".pdf">
</div>
七、一些别的上传类型
后缀:*.txt text/plain;*.ppt application/vnd.ms-powerpoint;*.zip application/zip;*.js text/javascript,application/javascript; *.gif image/gif
- 设置input上传类型
- 关于input设置成file类型上传文件后台获取不到
- HTML5的 input:file上传类型控制
- HTML5的 input:file上传类型控制
- HTML5的 input:file上传类型控制
- input只允许上传图片类型文件
- input上传指定类型的文件
- HTML5的 input:file上传类型控制
- HTML input-file 上传类型控制
- HTML5的 input:file上传类型控制
- HTML5的 input:file上传类型控制
- HTML5的 input:file上传类型控制
- HTML5的 input:file上传类型控制
- HTML5的 input:file上传类型控制
- HTML5的 input:file上传类型控制
- HTML5的 input:file上传类型控制
- HTML5的 input:file上传类型控制
- HTML5的input:file上传类型控制
- WARNING: vboxdrv kernel module is not loaded.
- Activity分析(上)
- iOS使用Reveal分析app界面
- 123
- cocos2d - JS 用角度计算向量
- 设置input上传类型
- 关于ios中的控件切换成中文的方法
- Java设计模式—适配器模式
- html和body之间空白解决
- 技术交流网站stackoverflow
- GetSystemDefaultLangID 取得系统默认ID对照表
- Duilib + libuv实践小程序
- 剑指Offer——由二叉树的前序中序重构
- 推荐一些国内的Jquery CDN免费服务