View Full Version : Submit url to script

05-06-2009, 04:33 AM
I need to know how to setup a form so I can submit an image url to this script. I know I'm missing something here. Thank Joe

<center><form name='src' action='' method='post'>
input type='text' size='45' name='url' />
<input type='submit' name='submit' value='Process It'>
<input type='reset' value='Clear'>

// The file
$filename = 'image/somefile.jpeg';
$percent = 0.5;

// Content type
header('Content-type: image/jpeg');

// Get new dimensions
list($width, $height) = getimagesize($filename);
$new_width = $width * $percent;
$new_height = $height * $percent;

// Resample
$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);

// Output
imagejpeg($image_p, null, 100);

05-06-2009, 04:46 AM
You're missing quite alot from the looks of it.

1) A FORM element 'action' attribute is missing a value, ie. the recieving script.
2) Your script doesn't handle any POST data
3) Your script will have to carefully validate the incoming request, eg. against a list of known images would be ideal.

PHP Manual:
Language Reference (http://www.php.net/langref)
Predefined Variables (http://www.php.net/manual/en/reserved.variables.php)