Incorrect File type when uploading PDF's

See all posts Reply

Incorrect File type when uploading PDF's new!
by aalmeida71, 14 years, 5 months ago
upload code:
$handle = new Upload($file, 'pt_BR');
$handle->allowed = array('text/pdf');
if ($handle->uploaded) {
  $handle->Process(stripslashes($DirTo));
}

Log information on the upload!
system information
- class version : 0.28
- GD version : 2.0.34
- supported image types : png jpg gif bmp
- open_basedir : no restriction
- language : pt_BR
source is an uploaded file
- upload OK
- file name OK
determining MIME type
- Checking MIME type with Fileinfo PECL extension
Fileinfo PECL extension not available
- Checking MIME type with UNIX file() command
UNIX file() command not availabled
- Checking MIME type with mime.magic file (mime_content_type())
mime_content_type() is not available
- Checking MIME type with getimagesize()
getimagesize() failed
- MIME type detected as application/force-download by browser
source variables
- You can use all these before calling process()
file_src_name : LLContabil-2009-02.pdf
file_src_name_body : LLContabil-2009-02
file_src_name_ext : pdf
file_src_pathname : G:\Temp\php38C1.tmp
file_src_mime : application/force-download
file_src_size : 47427 (max= 2097152)
file_src_error : 0
process file to attach/49\
- file size OK
- error: Tipo de arquivo incorreto.
Reply
Re: Incorrect File type when uploading PDF's new!
by colin, 14 years, 5 months ago
Your system doesn't detect MIME types properly, so the class has to rely on the information the browser gives. It also looks like the file is uploaded via Flash, which results in the MIME type sent by the browser to be application/force-download

Make sure that your system can detect MIME types properly, or that your browser sends the right MIME type. Note that I am not supporting the use of the class on Windows systems.Reply
Re: Incorrect File type when uploading PDF's new!
by aalmeida71, 14 years, 5 months ago
I'm not using flash, and at the time the log was generated I was using Firefox 3.0.15. Is there a specific version of Linux required?Reply
Re: Incorrect File type when uploading PDF's new!
by colin, 14 years, 5 months ago
No, no specific version of Linux is requeired. You can run the class fine on Windows too, as long as at least one of the MIME detection method is enabled. Check out the relevant PECL modules.Reply