Problem with Extension ... .txt instead of .jpg

See all posts See thread Reply

Re: Problem with Extension ... .txt instead of .jpg new!
by DJo, 16 years, 2 months ago
Nop, but I've got 2 different upload code ...

I just try the other and it's working:

The working code:
$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();
 
}                                            
}

And the code which is not working, extension .txt, but if we display the .txt it's a picture !

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();
 
}
}

But if I add convert jpg, it's working well ...Reply