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 a simple upload with a HTML input file. That's one works fine.
But now I'm using the class with FancyUpload Ajax script. And the upload is good, the file is well uploaded and renamed but there is no resizing or watermarking. Do you know why ?
There is my code:
$handle = new upload($_FILES['photoupload']);
if ($handle->uploaded) {
// $handle->file_new_name_body = $_FILES['img']['name'];
if ( !is_dir(BASE_PATH."www/images/billets/".date("Y-m")."/")) {
mkdir(BASE_PATH."www/images/billets/".date("Y-m")."/");
chmod(BASE_PATH."www/images/billets/".date("Y-m")."/", 0777);
}
// Génération de la miniature 100px largeur
$handle->jpeg_quality = 80;
$handle->image_resize = true;
$handle->image_x = 100;
$handle->image_ratio_y = true;
$handle->file_name_body_add = "_mini";
$handle->file_overwrite = true;
$handle->Process(BASE_PATH."www/images/billets/".date("Y-m")."/");
if ($handle->processed) {
$mini = $handle->file_dst_name;
}
// Génération de l'image pour insertion dans billet: 500px largeur
$handle->jpeg_quality = 80;
$handle->image_resize = true;
$handle->image_x = 500;
$handle->file_name_body_add = "_billet";
$handle->image_watermark = BASE_PATH."www/images/design/watermark/logo-50px.png";
$handle->image_watermark_position = 'BR';
$handle->image_ratio_y = true;
$handle->file_overwrite = true;
$handle->Process(BASE_PATH."www/images/billets/".date("Y-m")."/");
if ($handle->processed) {
$handle->clean();
$result['result'] = 'success';
$result['size'] = utf8_encode("Transféré: ".$handle->file_dst_name." et ".$mini." dans le repértoire ".str_replace(BASE_PATH."www/", "/",$handle->file_dst_path));
} else {
$handle->clean();
$result['result'] = 'failed';
$result['error'] = $handle->error;
}
}
system information
- GD version : 2.0.34
- supported image types : png jpg gif bmp
- open_basedir : no restriction
- language : en_GB
source is an uploaded file
- upload OK
- file name OK
- source variables
file_src_name : DSC_0021.JPG
file_src_name_body : DSC_0021
file_src_name_ext : jpg
file_src_pathname : /tmp/phpCthlLY
file_src_mime : application/octet-stream
file_src_size : 165268 (max= 2097152)
file_src_error : 0
process file to /var/www/images/billets/2008-11/
- file size OK
- file mime OK : application/octet-stream
- file name body add : _billet
- file name safe format
- destination variables
file_dst_path : /var/www/images/billets/2008-11/
file_dst_name_body : DSC_0021_billet
file_dst_name_ext : jpg
- no image operation, keep extension
- no auto_rename if same filename exists
- destination file details
file_dst_name : DSC_0021_billet.jpg
file_dst_pathname : /var/www/images/billets/2008-11/DSC_0021_billet.jpg
- no overwrite checking
- no image processing wanted
- process OK
cleanup
- delete temp file /tmp/phpCthlLY
That's strange, in my code, I ask it to resize by 500px width and tag with watermark logo, and nothing happens, I've got the image in the good folder and the good name, but with the original size ...
When you use a Flash uploader, the MIME type is rewritten to application/octet-stream. The class then considers the file as not being an image, and therefore all image manipulations are deactivated.
You should use the version 0.26RC2, which offers support for files uploaded through Flash.Reply
I'm using this class which is awesome !
I've got a simple upload with a HTML input file.
That's one works fine.
But now I'm using the class with FancyUpload Ajax script.
And the upload is good, the file is well uploaded and renamed but there is no resizing or watermarking. Do you know why ?
There is my code:
Thanks for your help.
That's strange, in my code, I ask it to resize by 500px width and tag with watermark logo, and nothing happens, I've got the image in the good folder and the good name, but with the original size ...
Could you help me ?
When you use a Flash uploader, the MIME type is rewritten to application/octet-stream. The class then considers the file as not being an image, and therefore all image manipulations are deactivated.
You should use the version 0.26RC2, which offers support for files uploaded through Flash.
This class is very useful !
So does it work with 0.26RC2?
I have the same problem. You are the best in uploading!!!! :)))
Thanks a lot!!!!