PDA

View Full Version : Upload and resize script


platkonijn
08-25-2004, 12:32 PM
I have an php upload script.
But I want also that the uploade file will be resized to a width of 400 px and the height automaticly scales with it.

But how can I integrate it ?

WHo can help me !

Script:

<?php
// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
// of $_FILES.

$uploaddir = "d:/ensimdata/anne-marie/Inetpub/wwwroot/img/"; // IIS kan niet om met relatieve paden, en heeft een absoluut pad op de server nodig
$uploadfile = "d:/ensimdata/anne-marie/Inetpub/wwwroot/img/". $_FILES['userfile']['name'];

print "<pre>";
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
print "File is valid, and was successfully uploaded. ";
print "Here's some more debugging info:\n";
print_r($_FILES);
}
else {
print "Possible file upload attack!* Here's some debugging info:\n";
print_r($_FILES);
}
print "</pre>";

?>

vosgien
08-25-2004, 09:13 PM
Hi,
Can't help you out directly here, but can point you in the direction of the PHP manual, look for either ImageCopyResized() or ImageCopyResampled
My current PHP book ( O'Reilly - Programming PHP) tells me that the first option may lead to jagged edges in the new image, the second, which is available in GD2.x gives smooth edges and clarity to resized images, however it is slower.
That should solve your problem, sorry that I can' help you on how to implement it
http://www.php.net/

Hope that helps

Vosgien