0

I have a basic php based file uploader script. What I am looking to do is after the file is uploaded if the file that was uploaded is an image mime type then convert it into a pdf

Attached is the code I am using. Also I have Imagemagick and Imagick module installed on my cpanel lunix based vps.

  if($thefileext =='jpg' || $thefileext =='png' || $thefileext =='jpeg')
    {
       echo "the filename is  $thefile"; //echoing to make sure if statement works
       $img = new Imagick("img/$thefile");
       $img->setImageFormat('pdf');
       $success = $img->writeImage("img/$thefile");
    }

My issue is when I try to upload a .jpg file it gets uploaded fine (so my php uploader script is working) however the above Imagick code does not seem to be working. I am calling it after the actual upload functionality of the script. Any suggestions?

Jayreis
  • 253
  • 1
  • 7
  • 28
  • 1
    Does `$thefile` contain an extension? Imagik defaults to the file extension of the filename specified, so you may just be ovewriting your jpg with a new jpg. http://www.php.net/manual/en/imagick.writeimage.php#refsect1-imagick.writeimage-parameters – cpilko Jun 05 '14 at 13:58

1 Answers1

0

Ahh ok I removed the file extention out of $thefile and it now is working thanks ;)

Jayreis
  • 253
  • 1
  • 7
  • 28