php - file upload validation returns application/force-download -
i have problem when uploading files web server. created validation in order limit uploads server, inspired post here on stackoverflow. idea user should able upload file types server in order avoid can upload scripts etc.
$upfile = $_files['cont2']; if($upfile) { $acceptable = array( 'application/pdf', //.pdf 'application/vnd.adobe.xdp+xml', //.pdf 'application/vnd.ms-excel', //.xls 'application/vnd.openxmlformats-officedocument.presentationml.presentation', //.pptx 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', //.ppsx 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', //.xlsx 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', //.xltx 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', //.docx 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', //.dotx 'application/vnd.ms-powerpoint', //.ppt 'application/onenote', //.onetoc 'audio/x-ms-wma', //.wma 'video/x-ms-wmv', //.wmv 'application/msword', //.doc 'application/vnd.ms-xpsdocument', //.xps 'audio/mpeg', //.mpga 'video/mpeg', //.mpeg 'video/mp4', //.mp4 'audio/mp4', //.mp4a 'application/mp4', //.mp4 'application/vnd.oasis.opendocument.presentation', //.odp 'application/vnd.oasis.opendocument.spreadsheet', //.ods 'application/vnd.oasis.opendocument.text', //.odt 'application/vnd.sun.xml.calc', //.sxc 'application/vnd.sun.xml.draw.template', //.std 'application/vnd.sun.xml.writer', //.sxw 'image/vnd.adobe.photoshop', //.psd 'text/plain', //.txt 'text/x-vcard', //.vcf 'application/xml', //.xml 'application/zip', //.zip 'application/x-rar-compressed', //.rar 'video/jpeg', 'text/calendar', 'video/x-flv', 'video/x-msvideo', 'application/x-shockwave-flash', 'image/jpeg', 'image/jpg', 'image/bmp', 'image/gif', 'image/png' ); if(!in_array($_files['cont2']['type'], $acceptable) && !empty($_files["cont2"]["type"])) die('<b>file format not allowed.</b>');
the problem validation process doesn't work. when upload .jpg image, works, tried pdf, , didn't work. tried find out type of pdf making simple
echo $_files['cont2']['type'];
and returned application/force-download. however, same piece of script worked on server in script file, same pdf. ideas problem , how can precisely solve it?
many in advance
Comments
Post a Comment