Reply to MIME type couldn't be detected

MIME type couldn't be detected new!
by Chaman, 15 years, 3 months ago
Hi

When I force the download of a file using your suggested code (from http://www.verot.net/res/sources/class.upload.html) it usually works fine:

$handle = new upload($_FILES['image_field']);
header('Content-type: ' . $handle->file_src_mime);
header("Content-Disposition: attachment; filename=".rawurlencode($handle->file_src_name).";");
echo $handle->Process();
die();

However if I try to do it for a MS Publisher file (.pub) then it fails to identify the mime type:
Log output:
system information
- class version : 0.26
- GD version : 2.0.28
- supported image types : png jpg gif bmp
- open_basedir : /home/****/:/tmp:/usr/local/lib/php/
- language : en_GB
source is a local file /home/****/class_fans_9.pub
- local file name OK
- MIME type detected as by UNIX file() command
- MIME type detected as by browser
- Try to guess MIME type from file extension (pub): MIME type set to
- MIME type couldn't be detected!
- source variables
file_src_name : class_fans_9.pub
file_src_name_body : class_fans_9
file_src_name_ext : pub
file_src_pathname : /home/****/class_fans_9.pub
file_src_mime :
file_src_size : 75776 (max= 2097152)
file_src_error : 0


Is there any way to add/check mime types manually, as i guess you can't possibly cater for all the hundreds of other file types out there which aren't in the functions which are checking...

Thanks.

BTW I found I had to add the following to make downloads work in IE6:
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);
Reply

Your reply

Name *
Email 
Title *
Text *
CAPTCHA image
Enter the code displayed on the image:
Click on the image to generate another one if it is hard to read it. The case is important