class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
I have tried adding this mime type, but it doesn't seem to work.
I also found application/x-mspublisher from http://filext.com/file-extension/PUB
This is my code (iin case i#I've added the code in the wrong place):
$handle = new upload(PATH_TO_ROOT.$row['dfilename']);
// attempted fixes for dodgy MS Publisher mime type
$handle->allowed = array('\012- application/msword');
$handle->allowed = array('application/x-mspublisher');
$handle->allowed = array('012- application/msword');
// extras
header('Cache-Control: maxage=10');
header('Pragma: public');
header("Expires: ".gmdate("D, d M Y H:i:s", mktime(date("H"), date("i"), date("s")+10, date("m"), date("d"), date("Y")))." GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Content-Length: ".$handle->file_src_size);
header('Content-type: ' . $handle->file_src_mime);
header("Content-Disposition: attachment; filename=".rawurlencode($handle->file_src_name).";");
header("Content-Transfer-Encoding: binary\n");
// capture log ready to email
$_SESSION['error'] = $handle->log;
$to = 'EMAIL_TO_ADMIN';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";// To send HTML mail, the Content-type header must be set
$headers .= 'From: '.EMAIL_FROM_WEBSITE;
$subject = WEBSITE_NAME . ' fetch data';
$message = ''.$_SESSION['error'].'';
$ok = @mail($to, $subject, $message, $headers);
echo $handle->Process();
die();
If the detection continues to fail (or indeed another bad type fails detection) I guess I could just see if file_src_mime = '' and then just provide a direct link to the file instead?Reply
I also found application/x-mspublisher from http://filext.com/file-extension/PUB
This is my code (iin case i#I've added the code in the wrong place):
If the detection continues to fail (or indeed another bad type fails detection) I guess I could just see if file_src_mime = '' and then just provide a direct link to the file instead?