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 noticed that when auto-converting images to a specified type (.png, .jpeg, etc.), the 'file_dest_ext' returns an incorrect value after processing is complete.
e.g. if I upload 'foo.jpg' and set image_convert = 'png', the image is saved as 'foo.png' but 'file_dest_ext' post-process returns 'jpg'.
Not sure if this is the intended effect, but for scripts that attempt to upload a file, then save info about the file to a DB, it helps if 'file_dest_ext' reflects the image type conversion. Code in question starts around line 2,873.
I noticed that when auto-converting images to a specified type (.png, .jpeg, etc.), the 'file_dest_ext' returns an incorrect value after processing is complete.
e.g. if I upload 'foo.jpg' and set image_convert = 'png', the image is saved as 'foo.png' but 'file_dest_ext' post-process returns 'jpg'.
Not sure if this is the intended effect, but for scripts that attempt to upload a file, then save info about the file to a DB, it helps if 'file_dest_ext' reflects the image type conversion. Code in question starts around line 2,873.
Thanks for the script,
--Chad
To fix it, you can replace the following code:
if ($this->image_convert=='') { $this->file_dst_name = $this->file_dst_name_body . (!empty($this->file_dst_name_ext) ? '.' . $this->file_dst_name_ext : ''); $this->log .= '- ' . _("image operation, keep extension") . 'with:'; } else { $this->file_dst_name = $this->file_dst_name_body . '.' . $this->image_convert; $this->log .= '- ' . _("image operation, change extension for conversion type") . '
'; }
if ($this->image_convert=='') { $this->file_dst_name = $this->file_dst_name_body . (!empty($this->file_dst_name_ext) ? '.' . $this->file_dst_name_ext : ''); $this->log .= '- ' . _("image operation, keep extension") . 'Thanks for pointing it out. It will be fixed in the next release.'; } else { $this->file_dst_name = $this->file_dst_name_body . '.' . $this->image_convert; $this->file_dst_name_ext = $this->image_convert; $this->log .= '- ' . _("image operation, change extension for conversion type") . '
'; }