Resizing uploaded image

I want to resize an image that has been uploaded. I have the following code to upload a file, which works fine.

$destdir = 'img';
$image = 'img'.date('U').'.'.$extn;
$destpath = $destdir.'/'.$image;
$tmp_name = $_FILES['image']['tmp_name'];
if ( !(is_uploaded_file($tmp_name) && move_uploaded_file($tmp_name, $destpath)) )
  echo '<p class="error">File ', $filename, ' could not be uploaded.</p>', "\n";

Do I need to put my resizing code after this or can I do it before the move_uploaded_file?

Thanks

Just food for thought, but I use this myself and saves me time of writing my own resizing script.

Resizing Link

Then all I have to do is :

if (!$picture['error']) {
    $newImage = $image->moveImage();
    $resizePic = new Resize($newImage);
    $resizePic->resizeImage(690, 530, 'exact');
    $resizePic->saveImage($newImage, 100);
    $result = $image->create($rename); // Save Path and Filename in MySQL:
    header("Location: index.php");
    exit();
}

Thanks @Pepster. It’s certainly a thought, although the resizing is not so much the problem. It’s just whether having uploaded the image I have to save it, then resize it and then save the resized image, or if I can miss out a step by resizing the uploaded image before saving it.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.