Forum Moderators: coopster

Message Too Old, No Replies

Reading File from Hard Drive

Just learning php

         

adni18

2:21 pm on Apr 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello. I am creating a resize script that takes a jpg image from the user's computer and resizes it to 768px for height, while retaining the original proportions. Below is my script, but how can I get the image from the user's computer, instead of reading it directly from the server?

<?php
$imgfile = 'smp.jpg';
header('Content-type: image/jpeg');

list($width, $height) = getimagesize($imgfile);
$newheight = 768;
$newwidth = $newheight * ($width / $height);

$thumb = ImageCreateTrueColor($newwidth,$newheight);
$source = imagecreatefromjpeg($imgfile);

imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);

imagejpeg($thumb);
?>

Stormfx

4:21 pm on Apr 30, 2005 (gmt 0)

10+ Year Member



First you'll have to have the file uploaded. Here's a bit coverage on that:

[us4.php.net...]

Of course, once the file is uploaded, your code should cover the rest. Just make sure the tmp directory that is used in your PHP configuration is set with the appropriate permissions. Hope that helps :)