Jump to content

[SOLVED] Move image to folder without move_uploaded_file()


alemapo

Recommended Posts

Hi,

I created my program to upload and move images to the correct folder and it worked great. Then decided to use imagemagick to reduce the size of the image. That also works perfectly through the imagemagick part. Now that I have my reduced image in a variable how do I move that to the correct folder now that I can no longer use move_uploaded_file()?  I have 2 functions - the first one uploads the image, checks the type, etc. The 2nd one does the actual move (and now the resize).  I'm only showing the second one here that deals with the move.  Any help or suggestions would be greatly appreciated!

Pamela

 

function move_image($full_path, $short_path)  {

 

  $original_image =  $_FILES['thefile']['tmp_name'];

 

  $size = GetImageSize($original_image);

   

  $new_image = $_FILES['thefile']['name'];

 

  $max_width = "300";

 

  $max_height = "300";

 

  exec("convert -size {$size[0]}x{$size[1]} $original_image -thumbnail      $max_widthx$max_height $new_image");

 

    echo "<img src=\"".$new_image."\">";

 

 

Note:  Where I have the echo of the image used to be my move_uploaded_file() before I put in the imagemagick.  But the image I want to move is now in $new_image instead of $_FILES['thefile']['tmp_name'] so I'm not sure how to get that in my folder.

 

Thanks in advance if you can help!  :)

 

Link to comment
Share on other sites

      exec("convert -size {$size[0]}x{$size[1]} $original_image -thumbnail      $max_widthx$max_height $new_image");

 

add the new absolute directory for new image

 

      exec("convert -size {$size[0]}x{$size[1]} $original_image -thumbnail      $max_widthx$max_height /var/www/html/$new_image");

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.