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

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']的值

时间: 2024-10-07 03:18:34

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

PHP -----上传文件

文件上传 如何上传文件?? -----------------------------------------------主页面----------------------------------------------- <title>无标题文档</title> </head> <body> <form action="chuli.php" method="post" enctype="multipa

隐藏iframe无刷新上传文件

首先ajax不能上传文件,这误导了我有段时间,今晚睡不着就照着说明做了个无刷新上传文件 其实原理很简单 <form enctype="multipart/form-data" method="POST" target="upload" action="http://localhost/class.upload.php" > <input type="file" name="upl

异步上传文件并获得返回值(完全跨域)

http://blog.csdn.net/lrz1011/article/details/7913992 异步上传文件并获得返回值(完全跨域)AJAX可以进行数据的异步请求,但对于文件和跨域问题却束手无策. Jsonp可以进行跨域数据的异步请求,但同样不能使用于文件. <form>表单可以进行跨域数据和文件的上传,但却会使页面跳转. 那么如何同时实现“异步”+“跨域”+“文件”+“返回值”这几个特性呢?方法如下: 原理: 将<form>表单通过一个iframe来submit,也就是

PHP上传文件时无法上传成功,$_FILES[&#39;screenshot&#39;][&#39;tmp_name&#39;]为空

最近在学习<HeadFirst PHP & MySQL>一书的第5章"使用存储在文件中的数据",做一个文件上传的应用时,出现了错误,就是文件无法成功上传.这个问题困扰了我很久,不过还好最后终于解决了.原因是我上传的图片文件大小超过了HTML 表单中 MAX_FILE_SIZE 选项指定的值32768Bytes即32KB导致无法上传成功. 我使用了XAMPP(Apache + MySQL + PHP + Perl)集成开发包和Zend Studio 10.6作为PHP

Java使用HttpURLConnection上传文件

从普通Web页面上传文件很简单,只需要在form标签叫上enctype="multipart/form-data"即可,剩余工作便都交给浏览器去完成数据收集并发送Http请求.但是如果没有页面的话要怎么上传文件呢? 由于脱离了浏览器的环境,我们就要自己去完成数据的收集并发送请求,所以就很麻烦了.首先我们来写个JSP页面并看看浏览器发出的Http请求是什么样的 JSP页面: <html> <head> <meta charset="UTF-8&qu

使用Servlet上传文件

使用浏览器向服务器上传文件其本质是打开了一个长连接并通过TCP方式传输数据.而需要的动作是客户端在表单中使用file域,并指定该file域的name值,然后在form中设定enctype的值为multipart/form-data和method值为post.其他就如同一般表单一样.示例如下: <form name="form" action="uploadbyservlet1" enctype="multipart/form-data" m

input(file)异步上传文件

页面 <input id="file" name="file" type="file"><button id="btn" type="button">上传</button> //异步上传文件var $file = $('#file');$('#btn').click(function() { var data = new FormData(); data.append('

利用iframe+from表单实现跨域上传文件

一.需要的材料 客户端需要一个HTML页面A其中包含一个iframe和一个form表单,一个页面B(我称之为客户端代理)里面包含对返回参数的处理: 服务端需要一个asp.net的一般处理程序用来处理上传文件并返回值. 二.原理图 有图才有真相,哈哈哈 三.客户端代码实现 1.页面A的实现 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>A页面</ti

android form表单上传文件

原文地址:http://menuz.iteye.com/blog/1282097 Android程序使用http上传文件 有时,在网络编程过程中需要向服务器上传文件.Multipart/form-data是上传文件的一种方式. Multipart/form-data其实就是浏览器用表单上传文件的方式.最常见的情境是:在写邮件时,向邮件后添加附件,附件通常使用表单添加,也就是用multipart/form-data格式上传到服务器.  Html代码   <form action="/Test