Jump to content

Passing an Variable from one PHP File to another


stublackett

Recommended Posts

Hi Guys,

 

I'm working on an image resizer, to create thumbnails for my page. The resizer works on principle of include a DIRECT link to the image. But what I want to do is put in the PHP Variable in the URL string, so that it points to that file and resizes it accordingly.

 

My code is as follows :

<img src="thumbnail.php?image=<?php echo $row_select_property['image_url']; ?>

 

Image Resize :

<?php 
// Resize Image To A Thumbnail

// The file you are resizing 

$image = '$_GET[image_url]'; 

//This will set our output to 45% of the original size 
$size = 0.45; 

// This sets it to a .jpg, but you can change this to png or gif 
header('Content-type: image/jpeg'); 

// Setting the resize parameters
list($width, $height) = getimagesize($image); 
$modwidth = $width * $size; 
$modheight = $height * $size; 

// Creating the Canvas 
$tn= imagecreatetruecolor($modwidth, $modheight); 
$source = imagecreatefromjpeg($image); 

// Resizing our image to fit the canvas 
imagecopyresized($tn, $source, 0, 0, 0, 0, $modwidth, $modheight, $width, $height); 

// Outputs a jpg image, you could change this to gif or png if needed 
imagejpeg($tn); 
?>

 

What I am trying to do is pass on the variable "image=<?php echo $row_select_property['image_url']; ?>" to the Thumbnail script. At the moment I am passing it through the URL string, but it doesnt  seem to load the graphic.

 

I'll try expand on this more, should you have questions as I am finding it a little difficult to explain.

 

Thanks in advance.

You are using $image = '$_GET[image_url]'; I'm pretty sure that won't retrieve the GET value from the URL.

 

Try using $image = $_GET['image_url'];, try this and see if it is the issue.

 

Regards, PaulRyan.

 

Tried that Cheers Paul, Wasnt correct but put me on the right root.

 

I needed...

$image = $_GET['image']; 

 

Solved, Thanks :)

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.