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.
I've got an error when I'm uploading a picture with Symfony Admin form. I upload a JPG file, then I manage this image with your great classe but the file get a .txt extension instead of a .jpg one. When I force convert jpg, the .jpg extension is well displayed, but I would like to use PNG files too.
system information - GD version : 2.0.34 - supported image types : png jpg gif bmp - open_basedir : no restriction - language : en_GB source is a local file /tmp/phppj3C9h - local file name OK - MIME type detected as image/jpeg by UNIX file() command - source variables file_src_name : phppj3C9h file_src_name_body : phppj3C9h file_src_name_ext : file_src_pathname : /tmp/phppj3C9h file_src_mime : image/jpeg file_src_size : 36753 (max= 8388608) file_src_error : 0 - source file is an image image_src_x : 1000 image_src_y : 804 image_src_pixels : 804000 image_src_type : jpg image_src_bits : 8 process file to /var/www/*************/web/images/produits/ - file size OK - script phppj3C9h renamed as phppj3C9h.txt! - file mime OK : text/plain - new file name body : mini_1 - file name safe format - destination variables file_dst_path : /var/www/*************/web/images/produits/ file_dst_name_body : mini_1 file_dst_name_ext : txt - image operation, keep extension - no auto_rename if same filename exists - destination file details file_dst_name : mini_1.txt file_dst_pathname : /var/www/*************/web/images/produits/mini_1.txt - no overwrite checking - image resizing or conversion wanted - source image is JPEG - setting destination file type to txt - resizing... use plain sizes resized image object created image_src_x y : 1000 x 804 image_dst_x y : 1 x 1 - converting... fills in transparency with default color - saving image... JPEG image created image objects destroyed - process OKReply
Re: Problem with Extension ... .txt instead of .jpg new!
system information - GD version : 2.0.34 - supported image types : png jpg gif bmp - open_basedir : no restriction - language : en_GB source is a local file /tmp/phpopCwHr - local file name OK - MIME type detected as image/png by UNIX file() command - source variables file_src_name : phpopCwHr file_src_name_body : phpopCwHr file_src_name_ext : file_src_pathname : /tmp/phpopCwHr file_src_mime : image/png file_src_size : 102997 (max= 8388608) file_src_error : 0 - source file is an image image_src_x : 450 image_src_y : 300 image_src_pixels : 135000 image_src_type : png image_src_bits : 8 process file to /var/www/*************/web/images/produits/galerie/ - file size OK - script phpopCwHr renamed as phpopCwHr.txt! - file mime OK : text/plain - new file name body : img_2-5 - file name safe format - destination variables file_dst_path : /var/www/*************/web/images/produits/galerie/ file_dst_name_body : img_2_5 file_dst_name_ext : txt - image operation, keep extension - no auto_rename if same filename exists - destination file details file_dst_name : img_2_5.txt file_dst_pathname : /var/www/*************/web/images/produits/galerie/img_2_5.txt - no overwrite checking - image resizing or conversion wanted - source image is PNG - setting destination file type to txt - resizing... calculate y size resized image object created image_src_x y : 450 x 300 image_dst_x y : 1 x 1 - converting... fills in transparency with default color - saving image... JPEG image created image objects destroyed - process OK
That's really strange. Do you have an idea ? Is it because I'm using Symfony before ?
It is indeed strange. It shouldn't behave like this. The MIME type is properly detected as being an image... but for some reason, the source file doesn't have an extension: file_src_name_ext : It should be something like: file_src_name_ext : jpg
Because of this inconsistency, the file is considered as a potential script, and adds the .txt extension.
What is the filename of the file you try to upload? What browser do you use? On which system? Which version of PHP? Apache?
As a temporary fix, you can disable the script checking:
Would you have a special install of PHP by any chance? Or maybe you run it in safe mode, or in some kind of hardened environment? Can you provide a link to your PHPInfo()?Reply
Re: Problem with Extension ... .txt instead of .jpg new!
I've got an error when I'm uploading a picture with Symfony Admin form.
I upload a JPG file, then I manage this image with your great classe but the file get a .txt extension instead of a .jpg one.
When I force convert jpg, the .jpg extension is well displayed, but I would like to use PNG files too.
Do you have an idea to soluce my problem ?
Thanks a lot.
system information
- GD version : 2.0.34
- supported image types : png jpg gif bmp
- open_basedir : no restriction
- language : en_GB
source is a local file /tmp/phppj3C9h
- local file name OK
- MIME type detected as image/jpeg by UNIX file() command
- source variables
file_src_name : phppj3C9h
file_src_name_body : phppj3C9h
file_src_name_ext :
file_src_pathname : /tmp/phppj3C9h
file_src_mime : image/jpeg
file_src_size : 36753 (max= 8388608)
file_src_error : 0
- source file is an image
image_src_x : 1000
image_src_y : 804
image_src_pixels : 804000
image_src_type : jpg
image_src_bits : 8
process file to /var/www/*************/web/images/produits/
- file size OK
- script phppj3C9h renamed as phppj3C9h.txt!
- file mime OK : text/plain
- new file name body : mini_1
- file name safe format
- destination variables
file_dst_path : /var/www/*************/web/images/produits/
file_dst_name_body : mini_1
file_dst_name_ext : txt
- image operation, keep extension
- no auto_rename if same filename exists
- destination file details
file_dst_name : mini_1.txt
file_dst_pathname : /var/www/*************/web/images/produits/mini_1.txt
- no overwrite checking
- image resizing or conversion wanted
- source image is JPEG
- setting destination file type to txt
- resizing...
use plain sizes
resized image object created
image_src_x y : 1000 x 804
image_dst_x y : 1 x 1
- converting...
fills in transparency with default color
- saving image...
JPEG image created
image objects destroyed
- process OK
system information
- GD version : 2.0.34
- supported image types : png jpg gif bmp
- open_basedir : no restriction
- language : en_GB
source is a local file /tmp/phpopCwHr
- local file name OK
- MIME type detected as image/png by UNIX file() command
- source variables
file_src_name : phpopCwHr
file_src_name_body : phpopCwHr
file_src_name_ext :
file_src_pathname : /tmp/phpopCwHr
file_src_mime : image/png
file_src_size : 102997 (max= 8388608)
file_src_error : 0
- source file is an image
image_src_x : 450
image_src_y : 300
image_src_pixels : 135000
image_src_type : png
image_src_bits : 8
process file to /var/www/*************/web/images/produits/galerie/
- file size OK
- script phpopCwHr renamed as phpopCwHr.txt!
- file mime OK : text/plain
- new file name body : img_2-5
- file name safe format
- destination variables
file_dst_path : /var/www/*************/web/images/produits/galerie/
file_dst_name_body : img_2_5
file_dst_name_ext : txt
- image operation, keep extension
- no auto_rename if same filename exists
- destination file details
file_dst_name : img_2_5.txt
file_dst_pathname : /var/www/*************/web/images/produits/galerie/img_2_5.txt
- no overwrite checking
- image resizing or conversion wanted
- source image is PNG
- setting destination file type to txt
- resizing...
calculate y size
resized image object created
image_src_x y : 450 x 300
image_dst_x y : 1 x 1
- converting...
fills in transparency with default color
- saving image...
JPEG image created
image objects destroyed
- process OK
That's really strange.
Do you have an idea ? Is it because I'm using Symfony before ?
This is my PHP Code:
Thanks for your help and for your class !
file_src_name_ext :
It should be something like:
file_src_name_ext : jpg
Because of this inconsistency, the file is considered as a potential script, and adds the .txt extension.
What is the filename of the file you try to upload? What browser do you use? On which system? Which version of PHP? Apache?
As a temporary fix, you can disable the script checking:
I've tried a lot of different pictures:
wii.jpg
ps3.png
MacBookPro.jpg
What browser do you use?
Firefox 3.0.5
On which system?
Client: Win XP
Serveur: Linux Debian
Which version of PHP?
5.2.8-0.dotdeb.1
Apache?
Apache/2.2.3
Strange !
Would you have a special install of PHP by any chance? Or maybe you run it in safe mode, or in some kind of hardened environment? Can you provide a link to your PHPInfo()?
I just try the other and it's working:
The working code:
And the code which is not working, extension .txt, but if we display the .txt it's a picture !
But if I add convert jpg, it's working well ...
mini_3.txt and 3.txt.txt
If you put <img src='3.txt.txt' /> It's working ... but not the good extension.