I'm trying an image upload program where the user will upload the image via a form on page 1.
Then on page two, I have the following code to do some resizing:
Code: Select all
$filename = $_FILES['temp']['name'];
$temporary_name = $_FILES['temp']['tmp_name'];
$mimetype = $_FILES['temp']['type'];
$filesize = $_FILES['temp']['size'];
if ($filename != ""){
//Open the image using the imagecreatefrom..() command based on the MIME type.
switch($mimetype) {
case "image/jpg":
case "image/jpeg":
case "image/pjpeg":
$i = imagecreatefromjpeg($temporary_name);
break;
case "image/gif":
$i = imagecreatefromgif($temporary_name);
break;
case "image/png":
$i = imagecreatefrompng($temporary_name);
break;
}
//Specify the size of the thumbnail
$dest_x = 250;
$dest_y = 250;
//Is the original bigger than the thumbnail dimensions?
if (imagesx($i) > $dest_x or imagesy($i) > $dest_y) {
//Is the width of the original bigger than the height?
if (imagesx($i) >= imagesy($i)) {
$thumb_x = $dest_x;
$thumb_y = imagesy($i)*($dest_x/imagesx($i));
} else {
$thumb_x = imagesx($i)*($dest_y/imagesy($i));
$thumb_y = $dest_y;
}
} else {
//Using the original dimensions
$thumb_x = imagesx($i);
$thumb_y = imagesy($i);
}
//Generate a new image at the size of the thumbnail
$thumb = imagecreatetruecolor($thumb_x,$thumb_y);
//Copy the original image data to it using resampling
imagecopyresampled($thumb, $i ,0, 0, 0, 0, $thumb_x, $thumb_y, imagesx($i), imagesy($i));
//imagetracker id
$tempid = rand(1,99999);
//Save the thumbnail
imagejpeg($thumb, "../tempimages/$tempid.jpg", 80);I tried passing $filename, $temporary_name, $mimetype, and $filesize to the next page, but it wouldn't work.
Is there some way to pass the exact same $_FILES info to the next page so I can work with it in a similar method there?
Thank you!
-- Abe --