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.
$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
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
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
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.
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.