0

I'm using class.upload.php to resize an image from a form and I would like to use the resized image on the fly to send it with phpMailer but my code below is not working ;((

The image is not send !

Without sending a mail the resize image works fine ;))

Thanks for your help...

$handle = new upload($_FILES['file']); 
if ($handle->uploaded) {
    //$handle->file_new_name_body   = 'image_resized';
    $handle->image_resize         = true;
    $handle->image_x              = 200;
    $handle->image_ratio_y        = true;
    $handle->image_no_enlarging   = true;
    $handle->jpeg_quality         = 50;

    $attach = base64_encode($handle->process());

    $mail->AddAttachment($attach, 'myimage.jpg');
}
Chris
  • 435
  • 1
  • 8
  • 21

1 Answers1

1

addAttachment reads file from local filesystem path, use addStringAttachment instead:

$mail->addStringAttachment($attach, 'myimage.jpg');

PHPMailer docs page: String Attachments

vstelmakh
  • 742
  • 1
  • 11
  • 19
  • Thanks so much ;)) That works with addStringAttachment. I just had to remove base64_encode – Chris Feb 20 '20 at 22:26