Reply to Re: Problem with Extension ... .txt instead of .jpg

Re: Problem with Extension ... .txt instead of .jpg new!
by DJo, 15 years, 10 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

Your reply

Name *
Email 
Title *
Text *
CAPTCHA image
Enter the code displayed on the image:
Click on the image to generate another one if it is hard to read it. The case is important