Para saber que tipo de archivo es el que va a subir el usuario colocamos en PHP.
$tipo =$_FILES['upload']['type'];
y lo comparamos con el tipo o tipos de archivos que permitimos.
if($tipo=="application/pdf"){
$bien=0;
}
Nota: Una vez realizada una aplicación derrepente no dejaba subir archivos y daba error como que el tipo de archivo no correspondía. Me maté la cabeza y probé muchas cosas hasta quitar el control.
El problema fue que el windows vista no respetaba: image/gif, y colocaba o los tipos de imágenes subidos image/xgif. El problema es que si no tienes ese tipo de ordenador no puedes controlar esos aspectos. De todas formas puedes subir un archvivo y realizar un echo para saber que tipo de archivo has subido.
List of MIME types
| MIME Type | Type of file | Associated extension |
|---|---|---|
| application/acad | AutoCAD files | dwg |
| application/clariscad | ClarisCAD files | ccad |
| application/drafting | Prelude drafting MATRA files | drw |
| application/dxf | AutoCAD files | dxf |
| application/i-deas | I-deas SDRC files | unv |
| application/iges | CAO IGES exchange format | igs,iges |
| application/octet-stream | Non-interpreted binary files | bin |
| application/oda | ODA files | oda |
| application/pdf | Adobe Acrobat files | |
| application/postscript | PostScript files | ai,eps,ps |
| application/pro_eng | ProEngineer files | prt |
| application/rtf | Rich text format | rtf |
| application/set | CAO SET files | set |
| application/sla | Stereolithography files | stl |
| application/solids | Solids MATRA files | dwg |
| application/step | STEP data files | step |
| application/vda | Surface files | vda |
| application/x-mif | Framemaker files | mif |
| application/x-csh | C-Shell Script (UNIX) | dwg |
| application/x-dvi | Dvi text files | dvi |
| application/hdf | Data files | hdf |
| application/x-latex | LaTEX files | latex |
| application/x-netcdf | NetCDF files | nc,cdf |
| application/x-sh | Bourne Shell Script | dwg |
| application/x-tcl | Tcl script | tcl |
| application/x-tex | Tex files | tex |
| application/x-texinfo | eMacs files | texinfo,texi |
| application/x-troff | Troff files | t,tr,troff |
| application/x-troff-man | Troff/macro man files | man |
| application/x-troff-me | Troff/macro ME files | me |
| application/x-troff-ms | Troff/macro MS files | ms |
| application/x-wais-source | Wais Source | src |
| application/x-bcpio | Binary CPIO | bcpio |
| application/x-cpio | Posix CPIO | cpio |
| application/x-gtar | GNU tar | gtar |
| application/x-shar | Shell archives | shar |
| application/x-sv4cpio | SVR4n CPIO | sv4cpio |
| application/x-sv4crc | SVR4 CPIO with CRC | sc4crc |
| application/x-tar | Compressed tar files | tar |
| application/x-ustar | Compressed Posix tar files | man |
| application/zip | Compressed ZIP files | man |
| audio/basic | Basic audio files | au,snd |
| audio/x-aiff | AIFF audio files | aif,aiff,aifc |
| audio/x-wav | Wave audio files | wav |
| image/gif | Gif images | man |
| image/ief | Exchange format images | ief |
| image/jpeg | Jpeg images | jpg,jpeg,jpe |
| image/tiff | Tiff images | tiff,tif |
| image/x-cmu-raster | Cmu raster | cmu |
| image/x-portable-anymap | PBM Anymap files | pnm |
| image/x-portable-bitmap | PBM Bitmap files | pbm |
| image/x-portable-graymap | PBM Graymap files | pgm |
| image/x-portable-pixmap | PBM Pixmap files | ppm |
| image/x-rgb | RGB image | rgb |
| image/x-xbitmap | X Bitmap images | xbm |
| image/x-xpixmap | X Pixmap images | xpm |
| image/x-xwindowdump | X Window dump images | man |
| multipart/x-zip | Zip archive files | zip |
| multipart/x-gzip | GNU zip archive files | gz,gzip |
| text/html | HTML files | htm,html |
| text/plain | Unformatted text files | txt,g,h,c,cc,hh,m,f90 |
| text/richtext | Rich text files | rtx |
| text/tab-separated-value | Text files with separation of values | tsv |
| text/x-setext | Struct text files | etx |
| video/mpeg | MPEG videos | mpeg,mpg,mpe |
| video/quicktime | QuickTime videos | qt,mov |
| video/msvideo | Microsoft Windows videos | avi |
| video/x-sgi-movie | MoviePlayer videos | movie |
| MIME Type | Type of file | Associated extension |
|---|---|---|
| application/acad | AutoCAD files | dwg |
| application/clariscad | ClarisCAD files | ccad |
| application/drafting | Prelude drafting MATRA files | drw |
| application/dxf | AutoCAD files | dxf |
| application/i-deas | I-deas SDRC files | unv |
| application/iges | CAO IGES exchange format | igs,iges |
| application/octet-stream | Non-interpreted binary files | bin |
| application/oda | ODA files | oda |
| application/pdf | Adobe Acrobat files | |
| application/postscript | PostScript files | ai,eps,ps |
| application/pro_eng | ProEngineer files | prt |
| application/rtf | Rich text format | rtf |
| application/set | CAO SET files | set |
| application/sla | Stereolithography files | stl |
| application/solids | Solids MATRA files | dwg |
| application/step | STEP data files | step |
| application/vda | Surface files | vda |
| application/x-mif | Framemaker files | mif |
| application/x-csh | C-Shell Script (UNIX) | dwg |
| application/x-dvi | Dvi text files | dvi |
| application/hdf | Data files | hdf |
| application/x-latex | LaTEX files | latex |
| application/x-netcdf | NetCDF files | nc,cdf |
| application/x-sh | Bourne Shell Script | dwg |
| application/x-tcl | Tcl script | tcl |
| application/x-tex | Tex files | tex |
| application/x-texinfo | eMacs files | texinfo,texi |
| application/x-troff | Troff files | t,tr,troff |
| application/x-troff-man | Troff/macro man files | man |
| application/x-troff-me | Troff/macro ME files | me |
| application/x-troff-ms | Troff/macro MS files | ms |
| application/x-wais-source | Wais Source | src |
| application/x-bcpio | Binary CPIO | bcpio |
| application/x-cpio | Posix CPIO | cpio |
| application/x-gtar | GNU tar | gtar |
| application/x-shar | Shell archives | shar |
| application/x-sv4cpio | SVR4n CPIO | sv4cpio |
| application/x-sv4crc | SVR4 CPIO with CRC | sc4crc |
| application/x-tar | Compressed tar files | tar |
| application/x-ustar | Compressed Posix tar files | man |
| application/zip | Compressed ZIP files | man |
| audio/basic | Basic audio files | au,snd |
| audio/x-aiff | AIFF audio files | aif,aiff,aifc |
| audio/x-wav | Wave audio files | wav |
| image/gif | Gif images | man |
| image/ief | Exchange format images | ief |
| image/jpeg | Jpeg images | jpg,jpeg,jpe |
| image/tiff | Tiff images | tiff,tif |
| image/x-cmu-raster | Cmu raster | cmu |
| image/x-portable-anymap | PBM Anymap files | pnm |
| image/x-portable-bitmap | PBM Bitmap files | pbm |
| image/x-portable-graymap | PBM Graymap files | pgm |
| image/x-portable-pixmap | PBM Pixmap files | ppm |
| image/x-rgb | RGB image | rgb |
| image/x-xbitmap | X Bitmap images | xbm |
| image/x-xpixmap | X Pixmap images | xpm |
| image/x-xwindowdump | X Window dump images | man |
| multipart/x-zip | Zip archive files | zip |
| multipart/x-gzip | GNU zip archive files | gz,gzip |
| text/html | HTML files | htm,html |
| text/plain | Unformatted text files | txt,g,h,c,cc,hh,m,f90 |
| text/richtext | Rich text files | rtx |
| text/tab-separated-value | Text files with separation of values | tsv |
| text/x-setext | Struct text files | etx |
| video/mpeg | MPEG videos | mpeg,mpg,mpe |
| video/quicktime | QuickTime videos | qt,mov |
| video/msvideo | Microsoft Windows videos | avi |
| video/x-sgi-movie | MoviePlayer videos | movie |