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

Posted C# java C++ 开源通信

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 上传文件 $_FILES['']['type']的值相关的知识,希望对你有一定的参考价值。

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

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

 

以上是关于php 上传文件 $_FILES['']['type']的值的主要内容,如果未能解决你的问题,请参考以下文章

php上传文件(上传后显示图片)

php上传图片没有文件名后缀

在网站后台用户上传的图片如何获得图片路径存入数据库(mysql) (php解决) 急!!!

在php中如何上传视频

php上传视频的代码,急求啊

PHP中上传文件的临时目录的问题