Jump to content

Help with image resize


Stephen68

Recommended Posts

I have a upload script that works great, now I'm trying to resize the image that is being upload.

When I add this code to the scrip it stops working, can anybody see what's wrong with out me

posting the whole script. If not I can clean it up and post it :)

 

<?php
        //Where the file is sotred on the sever
    $userfile_tmp = $_FILES['userfile'.$i]['tmp_name'];

    // Create an Image from it so we can do the resize
    $src = imagecreatefromjpeg($userfile_tmp);

// Capture the original size of the uploaded image
    list($width,$height)=getimagesize($userfile_tmp);

    $newwidth=250;
    $newheight=($height/$width)*250;
    $tmp=imagecreatetruecolor($newwidth,$newheight);

// this line actually does the image resizing, copying from the original
    // image into the $tmp image
    imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);


    //What the userfiles name was from the uploading user.
    $userfile_name = $_FILES['userfile'.$i]['name'];

    //Size of the file to be uploaded.
    $userfile_size = $_FILES['userfile'.$i]['size'];

    //Get the type of file that is being uploaded.
    $userfile_type = $_FILES['userfile'.$i]['type'];

    //Get error message if there are any.
    $userfile_error = $_FILES['userfile'.$i]['error'];

//Get the type of image E.G. ed_thumb or ed
$image_type = $_POST['dir'.$i];

    //Directory where to put the uploaded files.
    $dir = $_SERVER['DOCUMENT_ROOT']."/photos/".$_POST['dir'.$i]."/";



?>

Link to comment
https://forums.phpfreaks.com/topic/151631-help-with-image-resize/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.