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.
more info about the class
$handle = new upload($file->getTempName()); if ($handle->uploaded) { // Version mini $handle->jpeg_quality = 90; $handle->file_new_name_body = "img_".$img->getProduitsId()."-".$img->getId(); $handle->mime_check = false; $handle->auto_create_dir = true; $handle->dir_auto_chmod = true; $handle->dir_chmod = 0777; $handle->image_resize = true; // $handle->image_convert = 'jpg'; $handle->image_x = sfConfig::get('app_images_widthprodimages'); $handle->image_ratio_y = true; $handle->preserve_transparency = true; $handle->file_auto_rename = false; $handle->file_overwrite = true; $handle->Process($path); if ($handle->processed) { $handle->clean(); $finalImage = $handle->file_dst_name; } else { echo $handle->error; $handle->clean(); } }
if ($handle->uploaded) { // Version mini $handle->jpeg_quality = 90; $handle->file_new_name_body = "mini_".$produit->getId(); $handle->mime_check = false; $handle->auto_create_dir = true; $handle->dir_auto_chmod = true; $handle->dir_chmod = 0777; $handle->image_resize = true; $handle->image_x = sfConfig::get('app_images_widthproduitsmini', 150); $handle->image_y = sfConfig::get('app_images_heightproduitsmini', 100); $handle->file_auto_rename = false; $handle->file_overwrite = true; $handle->Process($path); // Version large $handle->jpeg_quality = 90; $handle->file_new_name_body = $produit->getId(); $handle->mime_check = false; $handle->auto_create_dir = true; $handle->dir_auto_chmod = true; $handle->dir_chmod = 0777; $handle->image_resize = true; $handle->image_x = sfConfig::get('app_images_widthproduitsnormal', 450); $handle->image_y = sfConfig::get('app_images_heightproduitsnormal', 300); $handle->preserve_transparency = true; $handle->file_auto_rename = false; $handle->file_overwrite = true; $handle->Process($path); if ($handle->processed) { $handle->clean(); $finalImage = $handle->file_dst_name; } else { echo $handle->error; $handle->clean(); } }
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 ...