Understand the value of PHP upload file $_files[' [' type ']

Source: Internet
Author: User
  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). The 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. }
  29. ?>

Copy Code

Where the file type and its value are listed below the file suffix file type 3gp video/3gppaab Application/x-authoware-binaam Application/x-authoware-mapaas Application/x-authoware-segai application/postscriptaif audio/x-aiffaifc Audio/x-aiffaiff audio/x-aiffals audio/ X-ALPHA5AMC Application/x-mpegani application/octet-streamasc text/plainasd application/astoundasf video/ X-MS-ASFASN application/astoundasp application/x-asapasx Video/x-ms-asfau Audio/basicavb application/ Octet-streamavi VIDEO/X-MSVIDEOAWB audio/amr-wbbcpio application/x-bcpiobin application/octet-streambld Application /bldbld2 application/bld2bmp application/x-ms-bmpbpk application/octet-streambz2 application/x-bzip2cal image/ X-CALSCCN Application/x-cnccco application/x-cocoacdf application/x-netcdfcgi magnus-internal/cgichat application/ X-chatclass APPLICATION/OCTET-STREAMCLP application/x-msclipcmx Application/x-cmxco application/x-cult3d-objectcod Image/cis-codcpio application/x-cpiocpt APPLICATION/MAC-COMPACTPROCRD application/x-mscardfilecsh application/ X-CSHCSM ChemICAL/X-CSMLCSML chemical/x-csmlcss text/csscur application/octet-streamdcm x-lml/x-evmdcr application/x-directordcx image/x-dcxdhtml text/htmldir Application/x-directordll application/octet-streamdmg Application/octet-streamdms Application/octet-streamdoc Application/msworddot Application/x-dotdvi APPLICATION/X-DVIDWF drawing/x-dwfdwg APPLICATION/X-AUTOCADDXF APPLICATION/X-AUTOCADDXR application/x-directorebk Application/x-expandedbookemb Chemical /X-EMBL-DL-NUCLEOTIDEEMBL chemical/x-embl-dl-nucleotideeps application/postscripteri image/x-eries audio/ Echospeechesl audio/echospeechetc application/x-earthtimeetx TEXT/X-SETEXTEVM x-lml/x-evmevy Application/x-envoyexe Application/octet-streamfh4 image/x-freehandfh5 IMAGE/X-FREEHANDFHC image/x-freehandfif image/fiffm application/ X-MAKERFPX image/x-fpxfvi Video/isivideogau CHEMICAL/X-GAUSSIAN-INPUTGCA application/x-gca-compressedgdb x-lml/ X-gdbgif Image/gifgps Application/x-gpsgtar application/x-gtargz application/x-gziphdf application/x-hdfhDM text/x-hdmlhdml text/x-hdmlhlp application/winhlphqx application/mac-binhex40htm text/htmlhtml text/htmlhts text/ Htmlice x-conference/x-cooltalkico application/octet-streamief image/iefifm image/gififs image/ifsimy audio/ Melodyins application/x-net-installips application/x-ipscriptipx application/x-ipixit Audio/x-moditz AUDIO/X-MODIVR I-WORLD/I-VRMLJ2K Image/j2kjad Text/vnd.sun.j2me.app-descriptorjam Application/x-jamjar application/ JAVA-ARCHIVEJNLP application/x-java-jnlp-filejpe image/jpegjpeg image/jpegjpg image/jpegjpz image/jpegjs Application /X-JAVASCRIPTJWC application/jwckjx Application/x-kjxlak X-lml/x-laklatex APPLICATION/X-LATEXLCC application/ FASTMANLCL APPLICATION/X-DIGITALLOCALCR Application/x-digitallocalgh Application/lghlha application/ Octet-streamlml x-lml/x-lmllmlpack x-lml/x-lmlpacklsf video/x-ms-asflsx video/x-ms-asflzh application/x-lzhm13 Application/x-msmediaviewm14 application/x-msmediaviewm15 audio/x-modm3u Audio/x-mpegurlm3url audio/x-mpegurlma1 Audio/ma1ma2 audio/ma2ma3 audio/ma3ma5 Audio/ma5man application/x-troff-manmap magnus-internal/imagemapmbd application/ MBEDLETMCT application/x-mascotmdb application/x-msaccessmdz Audio/x-modme Application/x-troff-memel Text/x-vmelmi Application/x-mifmid Audio/midimidi audio/midimif application/x-mifmil Image/x-calsmio audio/x-miommf application/ X-skt-lbsmng video/x-mngmny Application/x-msmoneymoc Application/x-mochamocha application/x-mochamod audio/x-modmof Application/x-yumekaramol chemical/x-mdl-molfilemop Chemical/x-mopac-inputmov Video/quicktimemovie video/ X-SGI-MOVIEMP2 Audio/x-mpegmp3 audio/x-mpegmp4 VIDEO/MP4MPC application/vnd.mpohun.certificatempe video/mpegmpeg Video/mpegmpg video/mpegmpg4 VIDEO/MP4MPGA audio/mpegmpn application/vnd.mophun.applicationmpp application/ Vnd.ms-projectmps APPLICATION/X-MAPSERVERMRL TEXT/X-MRMLMRM Application/x-mrmms application/x-troff-msmts APPLICATION/METASTREAMMTX Application/metastreammtz Application/metastreammzv Application/metastreamnar application/Zipnbmp image/nbmpnc application/x-netcdfndb x-lml/x-ndbndwn application/ndwnnif application/x-nifnmz application/ X-screamnokia-op-logo image/vnd.nok-oplogo-colornpx application/x-netfpxnsnd Audio/nsndnva Application/x-neva1oda Application/odaoom Application/x-atlasmate-pluginpac audio/x-pacpae Audio/x-epacpan application/x-panpbm image/ X-PORTABLE-BITMAPPCX image/x-pcxpda image/x-pdapdb chemical/x-pdbpdf APPLICATION/PDFPFR APPLICATION/FONT-TDPFRPGM Image/x-portable-graymappict image/x-pictpm APPLICATION/X-PERLPMD application/x-pmdpng image/pngpnm image/ X-PORTABLE-ANYMAPPNZ image/pngpot application/vnd.ms-powerpointppm Image/x-portable-pixmappps application/ Vnd.ms-powerpointppt APPLICATION/VND.MS-POWERPOINTPQF Application/x-cprplayerpqi APPLICATION/CPRPLAYERPRC Application/x-prcproxy Application/x-ns-proxy-autoconfigps application/postscriptptlk application/listenuppub APPLICATION/X-MSPUBLISHERPVX video/x-pv-pvxqcp audio/vnd.qcelpqt video/quicktimeqti image/x-quicktimeqtif image/ X-quickTIMER3T Text/vnd.rn-realtext3dra Audio/x-pn-realaudioram Audio/x-pn-realaudiorar Application/x-rar-compressedras IMAGE/X-CMU-RASTERRDF APPLICATION/RDF+XMLRF Image/vnd.rn-realflashrgb Image/x-rgbrlf APPLICATION/X-RICHLINKRM Audio /X-PN-REALAUDIORMF audio/x-rmfrmm audio/x-pn-realaudiormvb Audio/x-pn-realaudiornx application/ Vnd.rn-realplayerroff APPLICATION/X-TROFFRP image/vnd.rn-realpixrpm AUDIO/X-PN-REALAUDIO-PLUGINRT text/ Vnd.rn-realtextrte x-lml/x-gpsrtf application/rtfrtg application/metastreamrtx TEXT/RICHTEXTRV video/ VND.RN-REALVIDEORWC application/x-rogerwilcos3m audio/x-mods3z Audio/x-modsca APPLICATION/X-SUPERCARDSCD APPLICATION/X-MSSCHEDULESDF Application/e-scoresea APPLICATION/X-STUFFITSGM TEXT/X-SGMLSGML text/x-sgmlsh Application/x-shshar application/x-sharshtml magnus-internal/parsed-htmlshw application/presentationssi6 image/ Si6si7 image/vnd.stiwap.sissi9 image/vnd.lgtwap.sissis application/vnd.symbian.installsit APPLICATION/X-STUFFITSKD APPLICATION/X-KOANSKM application/x-KOANSKP application/x-koanskt APPLICATION/X-KOANSLC application/x-salsasmd audio/x-smdsmi application/smilsmil APPLICATION/SMILSMP application/studiomsmz audio/x-smdsnd audio/basicspc text/x-speechspl application/ FUTURESPLASHSPR application/x-spritesprite APPLICATION/X-SPRITESPT application/x-sptsrc application/ X-WAIS-SOURCESTK application/hyperstudiostm Audio/x-modsv4cpio APPLICATION/X-SV4CPIOSV4CRC APPLICATION/X-SV4CRCSVF Image/vndsvg IMAGE/SVG-XMLSVH image/svhsvr x-world/x-svrswf APPLICATION/X-SHOCKWAVE-FLASHSWFL application/ X-shockwave-flasht Application/x-trofftad application/octet-streamtalk Text/x-speechtar Application/x-tartaz APPLICATION/X-TARTBP APPLICATION/X-TIMBUKTUTBT application/x-timbuktutcl Application/x-tcltex application/ X-textexi application/x-texinfotexinfo application/x-texinfotgz application/x-tarthm application/vnd.eri.thmtif Image/tifftiff image/tifftki application/x-tkinedtkined Application/x-tkinedtoc application/toctoy image/toytr APPLICATION/X-TROFFTRK X-lml/X-GPSTRM Application/x-msterminaltsi audio/tsplayertsp application/dsptypetsv text/tab-separated-valuestsv text/ Tab-separated-valuesttf Application/octet-streamttz application/t-timetxt Text/plainult Audio/x-modustar Application/x-ustaruu Application/x-uuencodeuue APPLICATION/X-UUENCODEVCD application/x-cdlinkvcf text/x-vcardvdo Video/vdovib Audio/vibviv video/vivovivo VIDEO/VIVOVMD APPLICATION/VOCALTEC-MEDIA-DESCVMF application/ VOCALTEC-MEDIA-FILEVMI Application/x-dreamcast-vms-infovms Application/x-dreamcast-vmsvox audio/voxwarevqe audio/ X-TWINVQ-PLUGINVQF audio/x-twinvqvql audio/x-twinvqvre x-world/x-vreamvrml x-world/x-vrmlvrt X-WORLD/X-VRTVRW X-world/x-vreamvts workbook/formulaonewav audio/x-wavwax audio/x-ms-waxwbmp image/vnd.wap.wbmpweb application/ Vnd.xarawi Image/waveletwis application/x-installshieldwm video/x-ms-wmwma audio/x-ms-wmawmd application/ X-ms-wmdwmf application/x-msmetafilewml TEXT/VND.WAP.WMLWMLC application/vnd.wap.wmlcwmls text/ VND.WAP.WMLSCRIPTWMLSC ApplicatioN/vnd.wap.wmlscriptcwmlscript text/vnd.wap.wmlscriptwmv audio/x-ms-wmvwmx video/x-ms-wmxwmz application/ X-ms-wmzwpng image/x-up-wpngwpt x-lml/x-gpswri application/x-mswritewrl x-world/x-vrmlwrz x-world/x-vrmlws text/ VND.WAP.WMLSCRIPTWSC APPLICATION/VND.WAP.WMLSCRIPTCWV video/waveletwvx VIDEO/X-MS-WVXWXL application/x-wxlx-gzip Application/x-gzipxar APPLICATION/VND.XARAXBM Image/x-xbitmapxdm APPLICATION/X-XDMAXDMA APPLICATION/X-XDMAXDW Application/vnd.fujixerox.docuworksxht application/xhtml+xmlxhtm application/xhtml+xmlxhtml application/xhtml+ Xmlxla application/vnd.ms-excelxlc application/vnd.ms-excelxll application/x-excelxlm Application/vnd.ms-excelxls Application/vnd.ms-excelxlt application/vnd.ms-excelxlw application/vnd.ms-excelxm audio/x-modxml TEXT/XMLXMZ Audio /x-modxpi application/x-xpinstallxpm image/x-xpixmapxsit text/xmlxsl text/xmlxul text/xulxwd image/x-xwindowdumpxyz CHEMICAL/X-PDBYZ1 application/x-yz1z Application/x-compresszac application/x-zaurus-zaczip application/zip

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.