php 上传文件 $_FILES['']['type']的值

一个函数

  1. function upload_file($fname,$ftype,$fsize,$ferror,$ftmp_name,$fpath){
  2. date_default_timezone_set('PRC');
  3. $store_nm = date("YmdHis") . "-" . rand(10000,99999) . "-". strlen($fname)."-$fname";
  4. if($fname){
  5. if ( ( ($ftype == "image/gif") || ($ftype == "image/jpeg")|| ($ftype == "image/pjpeg"))
  6. && ($fsize < 20000000) ){
  7. if ($ferror > 0){
  8. //echo "Error: " . $ferror . "
    ";
  9. return 1;
  10. }else{
  11. /*
  12. echo "Upload: " . $fname . "
    ";
  13. echo "Type: " . $ftype . "
    ";
  14. echo "Size: " . ($fsize / 1024) . " Kb
    ";
  15. echo "Stored in: $fpath/$store_nm-$fname";
  16. */
  17. move_uploaded_file($ftmp_name,"$fpath/$store_nm");
  18. return $store_nm;
  19. }
  20. }else{
  21. //echo "Invalid file";
  22. return 2;
  23. }
  24. }else {
  25. //echo "no file";
  26. return 3;
  27. }
  28. }

其中对文件类型及其值,列表如下

  

  1. 文件后缀名 文件类型
  2.  3gp video/3gpp
  3.   aab application/x-authoware-bin
  4.   aam application/x-authoware-map
  5.   aas application/x-authoware-seg
  6.   ai application/postscript
  7.   aif audio/x-aiff
  8.   aifc audio/x-aiff
  9.   aiff audio/x-aiff
  10.   als audio/X-Alpha5
  11.   amc application/x-mpeg
  12.   ani application/octet-stream
  13.   asc text/plain
  14.   asd application/astound
  15.   asf video/x-ms-asf
  16.   asn application/astound
  17.   asp application/x-asap
  18.   asx video/x-ms-asf
  19.   au audio/basic
  20.   avb application/octet-stream
  21.   avi video/x-msvideo
  22.   awb audio/amr-wb
  23.   bcpio application/x-bcpio
  24.   bin application/octet-stream
  25.   bld application/bld
  26.   bld2 application/bld2
  27.   bmp application/x-MS-bmp
  28.   bpk application/octet-stream
  29.   bz2 application/x-bzip2
  30.   cal image/x-cals
  31.   ccn application/x-cnc
  32.   cco application/x-cocoa
  33.   cdf application/x-netcdf
  34.   cgi magnus-internal/cgi
  35.   chat application/x-chat
  36.   class application/octet-stream
  37.   clp application/x-msclip
  38.   cmx application/x-cmx
  39.   co application/x-cult3d-object
  40.   cod image/cis-cod
  41.   cpio application/x-cpio
  42.   cpt application/mac-compactpro
  43.   crd application/x-mscardfile
  44.   csh application/x-csh
  45.   csm chemical/x-csml
  46.   csml chemical/x-csml
  47.   css text/css
  48.   cur application/octet-stream
  49.   dcm x-lml/x-evm
  50.   dcr application/x-director
  51.   dcx image/x-dcx
  52.   dhtml text/html
  53.   dir application/x-director
  54.   dll application/octet-stream
  55.   dmg application/octet-stream
  56.   dms application/octet-stream
  57.   doc application/msword
  58.   dot application/x-dot
  59.   dvi application/x-dvi
  60.   dwf drawing/x-dwf
  61.   dwg application/x-autocad
  62.   dxf application/x-autocad
  63.   dxr application/x-director
  64.   ebk application/x-expandedbook
  65.   emb chemical/x-embl-dl-nucleotide
  66.   embl chemical/x-embl-dl-nucleotide
  67.   eps application/postscript
  68.   eri image/x-eri
  69.   es audio/echospeech
  70.   esl audio/echospeech
  71.   etc application/x-earthtime
  72.   etx text/x-setext
  73.   evm x-lml/x-evm
  74.   evy application/x-envoy
  75.   exe application/octet-stream
  76.   fh4 image/x-freehand
  77.   fh5 image/x-freehand
  78.   fhc image/x-freehand
  79.   fif image/fif
  80.   fm application/x-maker
  81.   fpx image/x-fpx
  82.   fvi video/isivideo
  83.   gau chemical/x-gaussian-input
  84.   gca application/x-gca-compressed
  85.   gdb x-lml/x-gdb
  86.   gif image/gif
  87.   gps application/x-gps
  88.   gtar application/x-gtar
  89.   gz application/x-gzip
  90.   hdf application/x-hdf
  91.   hdm text/x-hdml
  92.   hdml text/x-hdml
  93.   hlp application/winhlp
  94.   hqx application/mac-binhex40
  95.   htm text/html
  96.   html text/html
  97.   hts text/html
  98.   ice x-conference/x-cooltalk
  99.   ico application/octet-stream
  100.   ief image/ief
  101.   ifm image/gif
  102.   ifs image/ifs
  103.   imy audio/melody
  104.   ins application/x-NET-Install
  105.   ips application/x-ipscript
  106.   ipx application/x-ipix
  107.   it audio/x-mod
  108.   itz audio/x-mod
  109.   ivr i-world/i-vrml
  110.   j2k image/j2k
  111.   jad text/vnd.sun.j2me.app-descriptor
  112.   jam application/x-jam
  113.   jar application/java-archive
  114.   jnlp application/x-java-jnlp-file
  115.   jpe image/jpeg
  116.   jpeg image/jpeg
  117.   jpg image/jpeg
  118.   jpz image/jpeg
  119.   js application/x-javascript
  120.   jwc application/jwc
  121.   kjx application/x-kjx
  122.   lak x-lml/x-lak
  123.   latex application/x-latex
  124.   lcc application/fastman
  125.   lcl application/x-digitalloca
  126.   lcr application/x-digitalloca
  127.   lgh application/lgh
  128.   lha application/octet-stream
  129.   lml x-lml/x-lml
  130.   lmlpack x-lml/x-lmlpack
  131.   lsf video/x-ms-asf
  132.   lsx video/x-ms-asf
  133.   lzh application/x-lzh
  134.   m13 application/x-msmediaview
  135.   m14 application/x-msmediaview
  136.   m15 audio/x-mod
  137.   m3u audio/x-mpegurl
  138.   m3url audio/x-mpegurl
  139.   ma1 audio/ma1
  140.   ma2 audio/ma2
  141.   ma3 audio/ma3
  142.   ma5 audio/ma5
  143.   man application/x-troff-man
  144.   map magnus-internal/imagemap
  145.   mbd application/mbedlet
  146.   mct application/x-mascot
  147.   mdb application/x-msaccess
  148.   mdz audio/x-mod
  149.   me application/x-troff-me
  150.   mel text/x-vmel
  151.   mi application/x-mif
  152.   mid audio/midi
  153.   midi audio/midi
  154.   mif application/x-mif
  155.   mil image/x-cals
  156.   mio audio/x-mio
  157.   mmf application/x-skt-lbs
  158.   mng video/x-mng
  159.   mny application/x-msmoney
  160.   moc application/x-mocha
  161.   mocha application/x-mocha
  162.   mod audio/x-mod
  163.   mof application/x-yumekara
  164.   mol chemical/x-mdl-molfile
  165.   mop chemical/x-mopac-input
  166.   mov video/quicktime
  167.   movie video/x-sgi-movie
  168.   mp2 audio/x-mpeg
  169.   mp3 audio/x-mpeg
  170.   mp4 video/mp4
  171.   mpc application/vnd.mpohun.certificate
  172.   mpe video/mpeg
  173.   mpeg video/mpeg
  174.   mpg video/mpeg
  175.   mpg4 video/mp4
  176.   mpga audio/mpeg
  177.   mpn application/vnd.mophun.application
  178.   mpp application/vnd.ms-project
  179.   mps application/x-mapserver
  180.   mrl text/x-mrml
  181.   mrm application/x-mrm
  182.   ms application/x-troff-ms
  183.   mts application/metastream
  184.   mtx application/metastream
  185.   mtz application/metastream
  186.   mzv application/metastream
  187.   nar application/zip
  188.   nbmp image/nbmp
  189.   nc application/x-netcdf
  190.   ndb x-lml/x-ndb
  191.   ndwn application/ndwn
  192.   nif application/x-nif
  193.   nmz application/x-scream
  194.   nokia-op-logo image/vnd.nok-oplogo-color
  195.   npx application/x-netfpx
  196.   nsnd audio/nsnd
  197.   nva application/x-neva1
  198.   oda application/oda
  199.   oom application/x-AtlasMate-Plugin
  200.   pac audio/x-pac
  201.   pae audio/x-epac
  202.   pan application/x-pan
  203.   pbm image/x-portable-bitmap
  204.   pcx image/x-pcx
  205.   pda image/x-pda
  206.   pdb chemical/x-pdb
  207.   pdf application/pdf
  208.   pfr application/font-tdpfr
  209.   pgm image/x-portable-graymap
  210.   pict image/x-pict
  211.   pm application/x-perl
  212.   pmd application/x-pmd
  213.   png image/png
  214.   pnm image/x-portable-anymap
  215.   pnz image/png
  216.   pot application/vnd.ms-powerpoint
  217.   ppm image/x-portable-pixmap
  218.   pps application/vnd.ms-powerpoint
  219.   ppt application/vnd.ms-powerpoint
  220.   pqf application/x-cprplayer
  221.   pqi application/cprplayer
  222.   prc application/x-prc
  223.   proxy application/x-ns-proxy-autoconfig
  224.   ps application/postscript
  225.   ptlk application/listenup
  226.   pub application/x-mspublisher
  227.   pvx video/x-pv-pvx
  228.   qcp audio/vnd.qcelp
  229.   qt video/quicktime
  230.   qti image/x-quicktime
  231.   qtif image/x-quicktime
  232.   r3t text/vnd.rn-realtext3d
  233.   ra audio/x-pn-realaudio
  234.   ram audio/x-pn-realaudio
  235.   rar application/x-rar-compressed
  236.   ras image/x-cmu-raster
  237.   rdf application/rdf+xml
  238.   rf image/vnd.rn-realflash
  239.   rgb image/x-rgb
  240.   rlf application/x-richlink
  241.   rm audio/x-pn-realaudio
  242.   rmf audio/x-rmf
  243.   rmm audio/x-pn-realaudio
  244.   rmvb audio/x-pn-realaudio
  245.   rnx application/vnd.rn-realplayer
  246.   roff application/x-troff
  247.   rp image/vnd.rn-realpix
  248.   rpm audio/x-pn-realaudio-plugin
  249.   rt text/vnd.rn-realtext
  250.   rte x-lml/x-gps
  251.   rtf application/rtf
  252.   rtg application/metastream
  253.   rtx text/richtext
  254.   rv video/vnd.rn-realvideo
  255.   rwc application/x-rogerwilco
  256.   s3m audio/x-mod
  257.   s3z audio/x-mod
  258.   sca application/x-supercard
  259.   scd application/x-msschedule
  260.   sdf application/e-score
  261.   sea application/x-stuffit
  262.   sgm text/x-sgml
  263.   sgml text/x-sgml
  264.   sh application/x-sh
  265.   shar application/x-shar
  266.   shtml magnus-internal/parsed-html
  267.   shw application/presentations
  268.   si6 image/si6
  269.   si7 image/vnd.stiwap.sis
  270.   si9 image/vnd.lgtwap.sis
  271.   sis application/vnd.symbian.install
  272.   sit application/x-stuffit
  273.   skd application/x-Koan
  274.   skm application/x-Koan
  275.   skp application/x-Koan
  276.   skt application/x-Koan
  277.   slc application/x-salsa
  278.   smd audio/x-smd
  279.   smi application/smil
  280.   smil application/smil
  281.   smp application/studiom
  282.   smz audio/x-smd
  283.   snd audio/basic
  284.   spc text/x-speech
  285.   spl application/futuresplash
  286.   spr application/x-sprite
  287.   sprite application/x-sprite
  288.   spt application/x-spt
  289.   src application/x-wais-source
  290.   stk application/hyperstudio
  291.   stm audio/x-mod
  292.   sv4cpio application/x-sv4cpio
  293.   sv4crc application/x-sv4crc
  294.   svf image/vnd
  295.   svg image/svg-xml
  296.   svh image/svh
  297.   svr x-world/x-svr
  298.   swf application/x-shockwave-flash
  299.   swfl application/x-shockwave-flash
  300.   t application/x-troff
  301.   tad application/octet-stream
  302.   talk text/x-speech
  303.   tar application/x-tar
  304.   taz application/x-tar
  305.   tbp application/x-timbuktu
  306.   tbt application/x-timbuktu
  307.   tcl application/x-tcl
  308.   tex application/x-tex
  309.   texi application/x-texinfo
  310.   texinfo application/x-texinfo
  311.   tgz application/x-tar
  312.   thm application/vnd.eri.thm
  313.   tif image/tiff
  314.   tiff image/tiff
  315.   tki application/x-tkined
  316.   tkined application/x-tkined
  317.   toc application/toc
  318.   toy image/toy
  319.   tr application/x-troff
  320.   trk x-lml/x-gps
  321.   trm application/x-msterminal
  322.   tsi audio/tsplayer
  323.   tsp application/dsptype
  324.   tsv text/tab-separated-values
  325.   tsv text/tab-separated-values
  326.   ttf application/octet-stream
  327.   ttz application/t-time
  328.   txt text/plain
  329.   ult audio/x-mod
  330.   ustar application/x-ustar
  331.   uu application/x-uuencode
  332.   uue application/x-uuencode
  333.   vcd application/x-cdlink
  334.   vcf text/x-vcard
  335.   vdo video/vdo
  336.   vib audio/vib
  337.   viv video/vivo
  338.   vivo video/vivo
  339.   vmd application/vocaltec-media-desc
  340.   vmf application/vocaltec-media-file
  341.   vmi application/x-dreamcast-vms-info
  342.   vms application/x-dreamcast-vms
  343.   vox audio/voxware
  344.   vqe audio/x-twinvq-plugin
  345.   vqf audio/x-twinvq
  346.   vql audio/x-twinvq
  347.   vre x-world/x-vream
  348.   vrml x-world/x-vrml
  349.   vrt x-world/x-vrt
  350.   vrw x-world/x-vream
  351.   vts workbook/formulaone
  352.   wav audio/x-wav
  353.   wax audio/x-ms-wax
  354.   wbmp image/vnd.wap.wbmp
  355.   web application/vnd.xara
  356.   wi image/wavelet
  357.   wis application/x-InstallShield
  358.   wm video/x-ms-wm
  359.   wma audio/x-ms-wma
  360.   wmd application/x-ms-wmd
  361.   wmf application/x-msmetafile
  362.   wml text/vnd.wap.wml
  363.   wmlc application/vnd.wap.wmlc
  364.   wmls text/vnd.wap.wmlscript
  365.   wmlsc application/vnd.wap.wmlscriptc
  366.   wmlscript text/vnd.wap.wmlscript
  367.   wmv audio/x-ms-wmv
  368.   wmx video/x-ms-wmx
  369.   wmz application/x-ms-wmz
  370.   wpng image/x-up-wpng
  371.   wpt x-lml/x-gps
  372.   wri application/x-mswrite
  373.   wrl x-world/x-vrml
  374.   wrz x-world/x-vrml
  375.   ws text/vnd.wap.wmlscript
  376.   wsc application/vnd.wap.wmlscriptc
  377.   wv video/wavelet
  378.   wvx video/x-ms-wvx
  379.   wxl application/x-wxl
  380.   x-gzip application/x-gzip
  381.   xar application/vnd.xara
  382.   xbm image/x-xbitmap
  383.   xdm application/x-xdma
  384.   xdma application/x-xdma
  385.   xdw application/vnd.fujixerox.docuworks
  386.   xht application/xhtml+xml
  387.   xhtm application/xhtml+xml
  388.   xhtml application/xhtml+xml
  389.   xla application/vnd.ms-excel
  390.   xlc application/vnd.ms-excel
  391.   xll application/x-excel
  392.   xlm application/vnd.ms-excel
  393.   xls application/vnd.ms-excel
  394.   xlt application/vnd.ms-excel
  395.   xlw application/vnd.ms-excel
  396.   xm audio/x-mod
  397.   xml text/xml
  398.   xmz audio/x-mod
  399.   xpi application/x-xpinstall
  400.   xpm image/x-xpixmap
  401.   xsit text/xml
  402.   xsl text/xml
  403.   xul text/xul
  404.   xwd image/x-xwindowdump
  405.   xyz chemical/x-pdb
  406.   yz1 application/x-yz1
  407.   z application/x-compress
  408.   zac application/x-zaurus-zac
  409.   zip application/zip

php 上传文件 $_FILES['']['type']的值的更多相关文章

  1. 接口测试-Http状态码-postman上传文件

    转自:https://www.cnblogs.com/jiadan/articles/8546015.html 一. 接口   接口:什么是接口呢?接口一般来说有两种,一种是程序内部的接口,一种是系统 ...

  2. 4 django系列之HTML通过form标签来同时提交表单内容与上传文件

    preface 我们知道提交表单有2种方式,一种直接通过submit页面刷新方法来提交,另一种通过ajax异步局部刷新的方法提交,上回我们说了通过ajax来提交文件到后台,现在说说通过submit来提 ...

  3. 使用Servlet上传文件

    使用浏览器向服务器上传文件其本质是打开了一个长连接并通过TCP方式传输数据.而需要的动作是客户端在表单中使用file域,并指定该file域的name值,然后在form中设定enctype的值为mult ...

  4. jquery.form上传文件

    建立test文件夹 PHP代码: <?php //var_dump($_FILES['file']);exit; if(isset($_GET['option']) && $_G ...

  5. 伪ajax上传文件

    伪ajax上传文件   最近在折腾伪ajax异步上传文件. 网上搜索了一下,发现大部分方法的input file控件都局限于form中,如果是在form外的呢? 必须动态生成一个临时form和临时if ...

  6. Spring使用ajax异步上传文件

    单文件上传 <!-- 创建文件选择框 --> 文件上传 :<input type="file" id="file" name="fi ...

  7. springboot整合springmvc上传文件

    1.pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www ...

  8. Spring Boot 上传文件 获取项目根路径 物理地址 resttemplate上传文件

    springboot部署之后无法获取项目目录的问题: 之前看到网上有提问在开发一个springboot的项目时,在项目部署的时候遇到一个问题:就是我将项目导出为jar包,然后用java -jar 运行 ...

  9. 图片上传oss--先拿server端签名再上传oss,返回id值

    目前项目oss阿里云存储图片,图片上传主要步骤是:前端从服务端拿到签名signature,再上传到oss上busket里,上传成功返回图片id (imgId),最后再给server端: 注:官网上有个 ...

随机推荐

  1. @(报错)could not find the main class, Program will exit(已解决)

    原文 @(报错)could not find the main class, Program will exit(已解决)      (很抱歉,如果你希望能更加清楚地看清图片或是图上的文字的话,你可以 ...

  2. 清华集训2014 day1 task1 玛里苟斯

    题目 这可算是描述很简单的一道题了!但是不简单. \(S\)是一个可重集合,\(S = \{a_1, a_2, \dots, a_n \}\). 等概率随机取\(S\)的一个子集\(A = \{a_{ ...

  3. 十天学习PHP之第四天

    学习目的:学会连接数据库  PHP简直就是一个函数库,丰富的函数使PHP的某些地方相当简单.建议大家down一本PHP的函数手冊,总用得到. 我这里就简单说一下连接MYSQL数据库.  1.mysql ...

  4. NHibernate - HQL - 添加和更改

    添加: /// <summary> /// 等待乙方做出回应 A /// </summary> private void button2_Click_1(object send ...

  5. 怎样安装配置tomcat 8

    链接地址:http://jingyan.baidu.com/article/ff42efa91132a0c19e220208.html Apache tomcat 是目前最为流行的java网站开发的服 ...

  6. 百度地图api基本用法

    首先 ,如果想调用百度地图api,你需要获取一个百度地图api的密钥. 申请密钥很简单,在百度地图api的首页就有相关链接,填写相关信息百度就会给你一个密钥了. 接下来,就是引入百度地图的api 关键 ...

  7. 在Windows上使用CodeLite+MinGW+Clang进行开发

    前几天听说clang 3.4已经release了,然后我又手痒就折腾一下,在这里记录一下折腾的经过. 在以前就试过clang-cl+VC的开发环境,编译代码到是没发现什么大问题,有不少警告而已,不过c ...

  8. javax.servlet.http.HttpServletRequest;

    错误提示是没有引入javax.servlet.http.HttpServletRequest所在的包,编译错误. 这么添加: 项目-->右键-->properties-->java ...

  9. Swift - 邮件发送功能的实现

    使用MessageUI.framework框架除了可以发送短信,还能发送Email,步骤如下: (1)首先判断设备是否有发送邮件功能 (2)如果设备允许发送邮件,创建一个MFMailComposeVi ...

  10. Endnote X6 如何修改输出格式(output style)成为自己想要的输出格式:

    Endnote X6 如何修改输出格式(output style)成为自己想要的输出格式: (1)首先尝试在endnote output style 网站中查找: http://www.endnote ...