Renaming the extension of php to jpg

See all posts Reply

Renaming the extension of php to jpg  new!
by vandall, 15 years, 10 months ago
Hi!
Code:
$foo = new upload($_FILES['fileToUpload']);
$foo->allowed = array('image/jpg','image/png',
                      'image/gif','image/jpeg');
$foo->forbidden = array('application/*');
$foo->file_new_name_body = $filename;
$foo->image_convert = jpg;
$foo->image_resize          = true;
$foo->image_ratio_crop      = 'C';
$foo->image_x = 200;
$foo->image_y = 200;
$foo->Process('../img/users/200/');
Objective: To enable the user to upload a picture of a particular type.
If the script is "php", change the extension for example "JPG", he downloads.

How to get rid of this? thanksReply
Re: Renaming the extension of php to jpg  new!
by colin, 15 years, 10 months ago
Can you copy here the logs produced by the class, using version 0.28?Reply
Re: Renaming the extension of php to jpg  new!
by vandall, 15 years, 10 months ago
download php renamed png

system information
- class version : 0.28
- GD version : 2.0.34
...
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 image/png by browser
- can't retrieve image information. open_basedir restriction in place?

...

process file to ../upload/\
- file size OK
- file mime OK : image/png
- no image properties available, can't enforce dimension checks : image/png
- new file name ext : jpg
- file name safe format
- destination variables
file_dst_path : ../upload/\
file_dst_name_body : _video
file_dst_name_ext : jpg
- image operation, change extension for conversion type
- checking for auto_rename
auto_rename to _video_1.jpg
- destination file details
file_dst_name : _video_1.jpg
file_dst_pathname : ../upload/\_video_1.jpg
- _video_1.jpg doesn't exist already
- the file is not an image!
- no image processing wanted
- process OK


MIME type is not defined

may be something with the settings?Reply
Re: Renaming the extension of php to jpg  new!
by colin, 15 years, 10 months ago
Check your installation of PHP. You can see what extensions are loaded in the php.ini file. (Note that I cannot support the class on Windows).

Your system is unable to find out the MIME type of the file, so it cannot block a malicious file. Besides, you may have open_basedir enabled.Reply
Re: Renaming the extension of php to jpg  new!
by vandall, 15 years, 10 months ago
I actually use it on Windows.

Thank you for your help!Reply