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.
Ok I have found the error. It seems when I call the clean() function it treats the existing file as a "temp" one and and promptly deletes it. " delete temp file /uploads/avatars/avatar1.png"
By not calling clean() it works. This is the log:
system information - class version : 0.31 - operating system : WINNT - PHP version : 5.3.4 - GD version : 2.0.34 - supported image types : png jpg gif bmp - open_basedir : no restriction - upload_max_filesize : 100M (104857600 bytes) - language : en_GB source is a local file /uploads/avatars/avatar1.png - local file name OK 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() MIME type detected as image/png by PHP getimagesize() function - MIME validated as image/png source variables - You can use all these before calling process() file_src_name : avatar1.png file_src_name_body : avatar1 file_src_name_ext : png file_src_pathname : C:\wamp\www\mow_calc/themes/_default/uploads/avatars/avatar1.png file_src_mime : image/png file_src_size : 61257 (max= 104857600) file_src_error : 0 - source file is an image image_src_x : 300 image_src_y : 228 image_src_pixels : 68400 image_src_type : png image_src_bits : 8 process file to uploads/avatars/\ - file size OK - file mime OK : image/png - new file name body : avatar1 - file name safe format - destination variables file_dst_path : uploads/avatars/\ file_dst_name_body : avatar1 file_dst_name_ext : png - no auto_rename if same filename exists - destination file details file_dst_name : avatar1.png file_dst_pathname : /uploads/avatars/\avatar1.png - no overwrite checking - image resizing or conversion wanted - source image is PNG - setting destination file type to png - resizing... use plain sizes resized image object created image_src_x y : 300 x 228 image_dst_x y : 100 x 100 - converting... - saving image... PNG image created image objects destroyed - process OK cleanup - delete temp file /uploads/avatars/avatar1.pngReply
By not calling clean() it works. This is the log:
system information
- class version : 0.31
- operating system : WINNT
- PHP version : 5.3.4
- GD version : 2.0.34
- supported image types : png jpg gif bmp
- open_basedir : no restriction
- upload_max_filesize : 100M (104857600 bytes)
- language : en_GB
source is a local file /uploads/avatars/avatar1.png
- local file name OK
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()
MIME type detected as image/png by PHP getimagesize() function
- MIME validated as image/png
source variables
- You can use all these before calling process()
file_src_name : avatar1.png
file_src_name_body : avatar1
file_src_name_ext : png
file_src_pathname : C:\wamp\www\mow_calc/themes/_default/uploads/avatars/avatar1.png
file_src_mime : image/png
file_src_size : 61257 (max= 104857600)
file_src_error : 0
- source file is an image
image_src_x : 300
image_src_y : 228
image_src_pixels : 68400
image_src_type : png
image_src_bits : 8
process file to uploads/avatars/\
- file size OK
- file mime OK : image/png
- new file name body : avatar1
- file name safe format
- destination variables
file_dst_path : uploads/avatars/\
file_dst_name_body : avatar1
file_dst_name_ext : png
- no auto_rename if same filename exists
- destination file details
file_dst_name : avatar1.png
file_dst_pathname : /uploads/avatars/\avatar1.png
- no overwrite checking
- image resizing or conversion wanted
- source image is PNG
- setting destination file type to png
- resizing...
use plain sizes
resized image object created
image_src_x y : 300 x 228
image_dst_x y : 100 x 100
- converting...
- saving image...
PNG image created
image objects destroyed
- process OK
cleanup
- delete temp file /uploads/avatars/avatar1.png