You'd need to use the GD library for that. Be sure you have GD enabled/installed on your server, otherwise this will not work. Additionally, be sure that "accesscontrol.php" doesn't call any headers before hand, otherwise, the image resizing functinos for the imagejpeg header will not work either, and you'll return errors.
Code:
PHP Code:
<?php
include_once "accesscontrol.php";
$bdir="../member_image/";
if (isset($submitok) && $_FILES[userfile][size] > '0')
{
if (empty($image_name))
{
echo "<center><span class=TNA>You left blank some of the required fields. </span></center>";
}
else
{
$image_id = time()."_".$_FILES[userfile][name];
copy($_FILES[userfile][tmp_name], "../member_image/$image_id");
$filename = $_FILES[userfile][tmp_name];
$newname = "thumb".$filename;
header('Content-type: image/jpeg');
list($width, $height) = getimagesize($filename);
$newwidth = 100;
$newheight = 100;
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($filename);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
imagejpeg($thumb, $newname);
imagedestroy($thumb);
unlink($filename);
rename($newname, $filename);
$q2 = "update members_info set
image_name = \"$_POST[image_name]\",
image_id = \"$image_id\"
where uname = '$_SESSION[uname]' ";
$r2 = mysql_query($q2) or die(mysql_error());
header("location:s_upload.php");
exit();
}
}
unset($submitok);
unset($userfile);
?>
HTH
Bookmarks