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.
Also, is it not possible to force the script to try to handle it as the filetype of the name extension, in cases where it fails detecting mime?
system information - class version : 0.32 - operating system : Linux - PHP version : 5.3.3-7+squeeze25 - GD version : 2.0 - supported image types : png jpg gif bmp - open_basedir : /home/:/tmp/:/usr/lib/php5/:/usr/share/php:/usr/local/php5-suphp/:/usr/bin/:/usr/local/bin/:/bin/ - upload_max_filesize : 128M (134217728 bytes) - language : en_GB source is an uploaded file - upload OK - file name OK determining MIME type - Checking MIME type with Fileinfo PECL extension MAGIC path will not be used MIME type detected as application/x-empty; charset=binary by Fileinfo PECL extension - MIME validated as application/x-empty source variables - You can use all these before calling process() file_src_name : IMG_3579.JPG file_src_name_body : IMG_3579 file_src_name_ext : jpg file_src_pathname : /tmp/php0oY6pm file_src_mime : application/x-empty file_src_size : -195 (max= 134217728) file_src_error : 0 process file to /home/1/w/xxx/ - file size OK - error: Incorrect type of file.Reply
Re: Incorrect type of file - detected as application/x-empty new!
It looks like your system is reporting an incorrect file size for the upload file. file_src_size is equal to -195, which is weird. This explains also why the Filenfo extension reports the application/x-empty MIME: it reports the MIME type for an empty file.
Check that the upload works with your PHP setup, and that the file is actually uploaded.
Besides, if MIME detection fails, then the extension is used. But in your case, the MIME is properly detected.Reply
Also, is it not possible to force the script to try to handle it as the filetype of the name extension, in cases where it fails detecting mime?
system information
- class version : 0.32
- operating system : Linux
- PHP version : 5.3.3-7+squeeze25
- GD version : 2.0
- supported image types : png jpg gif bmp
- open_basedir : /home/:/tmp/:/usr/lib/php5/:/usr/share/php:/usr/local/php5-suphp/:/usr/bin/:/usr/local/bin/:/bin/
- upload_max_filesize : 128M (134217728 bytes)
- language : en_GB
source is an uploaded file
- upload OK
- file name OK
determining MIME type
- Checking MIME type with Fileinfo PECL extension
MAGIC path will not be used
MIME type detected as application/x-empty; charset=binary by Fileinfo PECL extension
- MIME validated as application/x-empty
source variables
- You can use all these before calling process()
file_src_name : IMG_3579.JPG
file_src_name_body : IMG_3579
file_src_name_ext : jpg
file_src_pathname : /tmp/php0oY6pm
file_src_mime : application/x-empty
file_src_size : -195 (max= 134217728)
file_src_error : 0
process file to /home/1/w/xxx/
- file size OK
- error: Incorrect type of file.
Check that the upload works with your PHP setup, and that the file is actually uploaded.
Besides, if MIME detection fails, then the extension is used. But in your case, the MIME is properly detected.