PHP上传文件–后缀名与文件类型对照表

 $error = $_FILES['upf']['error'];

文件的类型MIME (Multipurpose Internet Mail Extensions) 是描述消息内容类型的因特网标准,在w3school提供了MIME的参考手册,但可是并没有区别浏览器之间的区别,所以并不完全可用。最好还是自己测试。下面是我自己写代码测试的结果,绝对

 $name = $_FILES['upf']['name'];
 $type = $_FILES['upf']['type'];

准确实用。


                 
 
                       该对应表包含:

 


php上传图片文件(gif,jpg,bmp,png,psd,ico)
php上传压缩文件(rar,7z,zip)
php上传可执行文件(exe)
php上传视频文件,音乐文件,歌词文件(avi,rmvb,3gp,flv,mp3,wav,krc,lrc)
php上传文本文件和文档文件(word->doc,excel->xls,幻灯片->ppt,pdf,chm)
php上传数据库文件(access文件,sql文件,con文件,日志文件log, dat文件)
php上传网页文件,脚本文件,字体文件(ini,php,html,htm,字体文件:ttf,fon, js ,xml)
php上传其他文件(class类文件,dll动态加载库文件)
 

 


              史上最完全oophper亲测版php文件上传之文件类型对应表,ie,火狐各一份。
 

 


            IE下
id后缀名php识别出的文件类型
0gifimage/gif
1jpgimage/jpeg
2pngimage/png
3bmpimage/bmp
4psdapplication/octet-stream
5icoimage/x-icon
6rarapplication/octet-stream
7zipapplication/zip
87zapplication/octet-stream
9exeapplication/octet-stream
10avivideo/avi
11rmvbapplication/vnd.rn-realmedia-vbr
123gpapplication/octet-stream
13flvapplication/octet-stream
14mp3audio/mpeg
15wavaudio/wav
16krcapplication/octet-stream
17lrcapplication/octet-stream
18txttext/plain
19docapplication/msword
20xlsapplication/vnd.ms-excel
21pptapplication/vnd.ms-powerpoint
22pdfapplication/pdf
23chmapplication/octet-stream
24mdbapplication/msaccess
25sqlapplication/octet-stream
26conapplication/octet-stream
27logtext/plain
28datapplication/octet-stream
29iniapplication/octet-stream
30phpapplication/octet-stream
31htmltext/html
32htmtext/html
33ttfapplication/octet-stream
34fonapplication/octet-stream
35jsapplication/x-javascript
36xmltext/xml
37dllapplication/octet-stream
38dllapplication/octet-stream

 


Firefox下   
id后缀名php识别出的文件类型
0gifimage/gif
1jpgimage/pjpeg
2pngimage/x-png
3bmpimage/bmp
4psdapplication/octet-stream
5icoimage/x-icon
6rarapplication/octet-stream
7zipapplication/x-zip-compressed
87zapplication/octet-stream
9exeapplication/octet-stream
10avivideo/avi
11rmvbapplication/vnd.rn-realmedia-vbr
123gpapplication/octet-stream
13flvapplication/octet-stream
14mp3audio/mpeg
15wavaudio/wav
16krcapplication/octet-stream
17lrcapplication/octet-stream
18txttext/plain
19docapplication/msword
20xlsapplication/vnd.ms-excel
21pptapplication/vnd.ms-powerpoint
22pdfapplication/pdf
23chmapplication/octet-stream
24mdbapplication/msaccess
25sqltext/plain
26conapplication/octet-stream
27logtext/plain
28dattext/plain
29iniapplication/octet-stream
30phpapplication/octet-stream
31htmltext/html
32htmtext/html
33ttfapplication/octet-stream
34fonapplication/octet-stream
35jstext/html
36xmltext/xml
37dllapplication/octet-stream
38classapplication/java

 

 $error = $_FILES['upf']['error'];
 $name = $_FILES['upf']['name'];
 $type = $_FILES['upf']['type'];

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值