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.
The folowing wont do anything else than upload the image.. (log below)
$handle = new Upload($_FILES['my_field'],'se_SE');
if ($handle->uploaded) {
// needed to set this to prevent the
// script from autorenaming images...
$handle->no_script = false;
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_x = 400;
$handle->Process("test");
process file to test/ - file size OK - file mime OK : text/plain - file name safe format - destination variables file_dst_path : test/ file_dst_name_body : asd file_dst_name_ext : jpg - no image operation, keep extension - checking for auto_rename auto_rename to asd_2.jpg - destination file details file_dst_name : asd_2.jpg file_dst_pathname : test/asd_2.jpg - asd_2.jpg doesn't exist already - no image processing wanted - process OKReply
system information - class version : 0.28RC3 - GD version : 2.0.34 - supported image types : png jpg gif bmp - open_basedir : no restriction - language : se_SE source is an uploaded file - upload OK - file name OK determining MIME type - Checking MIME type with Fileinfo PECL extension MAGIC path defaults to /usr/share/file/magic Fileinfo PECL extension failed (finfo_open) - Checking MIME type with UNIX file() command UNIX file() command failed - Checking MIME type with mime.magic file (mime_content_type()) MIME type detected as text/plain by mime_content_type() source variables - You can use all these before calling process() file_src_name : asd.JPG file_src_name_body : asd file_src_name_ext : jpg file_src_pathname : /tmp/phpt7OYmn file_src_mime : text/plain file_src_size : 17412 (max= 104857600) file_src_error : 0 process file to test/ - file size OK - script asd.JPG renamed as asd.JPG.txt! - file mime OK : text/plain - file name safe format - destination variables file_dst_path : test/ file_dst_name_body : asd file_dst_name_ext : jpg.txt - no image operation, keep extension - checking for auto_rename auto_rename to asd_1.jpg.txt - destination file details file_dst_name : asd_1.jpg.txt file_dst_pathname : test/asd_1.jpg.txt - asd_1.jpg.txt doesn't exist already - no image processing wanted - process OK cleanup - delete temp file /tmp/phpt7OYmnReply
I rent a server, could this be the problem? (from php info)
mime_magic mime_magic support invalid magic file, disabled
Directive Local Value Master Value mime_magic.debug Off Off mime_magic.magicfile /hsphere/local/config/httpd/mime.types /hsphere/local/config/httpd/mime.typesReply
I tried to deactivate the mine_magic (as I saw in the config that there is a way to check with "getimagesize") and then it works, seems like "getimagesize" can do the trick :)Reply
You shouldn't use no_script to prevent the image from being renamed. Use file_auto_rename instead (set it to false).
In fact, your problem is different: the MIME type is detected as text/plain. Are you sure you are uploading an image? In any case, there is no image processing because the class thinks that your file is not a valid image.
Can you try with this new version 0.28RC3? This version gives more information about MIME type detection methods. Copy and paste the log here again.Reply
process file to test/
- file size OK
- file mime OK : text/plain
- file name safe format
- destination variables
file_dst_path : test/
file_dst_name_body : asd
file_dst_name_ext : jpg
- no image operation, keep extension
- checking for auto_rename
auto_rename to asd_2.jpg
- destination file details
file_dst_name : asd_2.jpg
file_dst_pathname : test/asd_2.jpg
- asd_2.jpg doesn't exist already
- no image processing wanted
- process OK
system information
- class version : 0.28RC3
- GD version : 2.0.34
- supported image types : png jpg gif bmp
- open_basedir : no restriction
- language : se_SE
source is an uploaded file
- upload OK
- file name OK
determining MIME type
- Checking MIME type with Fileinfo PECL extension
MAGIC path defaults to /usr/share/file/magic
Fileinfo PECL extension failed (finfo_open)
- Checking MIME type with UNIX file() command
UNIX file() command failed
- Checking MIME type with mime.magic file (mime_content_type())
MIME type detected as text/plain by mime_content_type()
source variables
- You can use all these before calling process()
file_src_name : asd.JPG
file_src_name_body : asd
file_src_name_ext : jpg
file_src_pathname : /tmp/phpt7OYmn
file_src_mime : text/plain
file_src_size : 17412 (max= 104857600)
file_src_error : 0
process file to test/
- file size OK
- script asd.JPG renamed as asd.JPG.txt!
- file mime OK : text/plain
- file name safe format
- destination variables
file_dst_path : test/
file_dst_name_body : asd
file_dst_name_ext : jpg.txt
- no image operation, keep extension
- checking for auto_rename
auto_rename to asd_1.jpg.txt
- destination file details
file_dst_name : asd_1.jpg.txt
file_dst_pathname : test/asd_1.jpg.txt
- asd_1.jpg.txt doesn't exist already
- no image processing wanted
- process OK
cleanup
- delete temp file /tmp/phpt7OYmn
mime_magic
mime_magic support invalid magic file, disabled
Directive Local Value Master Value
mime_magic.debug Off Off
mime_magic.magicfile /hsphere/local/config/httpd/mime.types /hsphere/local/config/httpd/mime.types
In fact, your problem is different: the MIME type is detected as text/plain. Are you sure you are uploading an image? In any case, there is no image processing because the class thinks that your file is not a valid image.
Can you try with this new version 0.28RC3? This version gives more information about MIME type detection methods. Copy and paste the log here again.
Also, thanks for the fast answer!