For the uploading part, here's some basic code:
<?php
if(@$_POST['MAX_FILE_SIZE']){ // If it is actually uploading
something...
$uploadfile = $uploaddir . basename($_FILE S['userfile']['name']);
//SET YOUR OWN UPLOAD DIR (absolute)
if (move_uploaded_ file($_FILES['userfile']['tmp_name'], $uploadfile)){
echo "File was successfully uploaded!\n You can access the file at:
http://".ROOT_DOMAIN.$ uploaddir.basen ame($_FILES['userfile']['name'])."\n";
} else {
echo "Error! File was not uploaded!\n";
};
};
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?admin=<?php echo
ADMIN_PAGE; ?>" method="POST" enctype="multip art/form-data">
<input type="hidden" name="MAX_FILE_ SIZE" value="300000" />
<input type="file" name="userfile" /><br />
<input type="submit" value="Upload" />
</form>
You can find a basic image resizing script @ php.net under GD2
functions -
<?php
function CreateThumb($fi le,$maxwdt,$max hgt, $dest) {
list($owdt,$ohg t,$otype)=@geti magesize($file) ;
switch($otype) {
case 1: $newimg=imagecr eatefromgif($fi le); break;
case 2: $newimg=imagecr eatefromjpeg($f ile); break;
case 3: $newimg=imagecr eatefrompng($fi le); break;
default: echo "Unkown filetype (file $file, typ $otype)"; return;
}
if($newimg) {
if($owdt>1500 || $ohgt>1200)
list($owdt, $ohgt) = Resample($newim g, $owdt, $ohgt,
1024,768,0);
Resample($newim g, $owdt, $ohgt, $maxwdt, $maxhgt);
if(!$dest) return $newimg;
if(!is_dir(dirn ame($dest)))
mkdir(dirname($ dest));
switch($otype) {
case 1: imagegif($newim g,dest); break;
case 2: imagejpeg($newi mg,$dest,90); break;
case 3: imagepng($newim g,$dest); break;
}
imagedestroy($n ewimg);
chmod($dest,064 4);
}
}
function Resample(&$img, $owdt, $ohgt, $maxwdt, $maxhgt, $quality=1) {
if(!$maxwdt) $divwdt=0;
else $divwdt=Max(1,$ owdt/$maxwdt);
if(!$maxhgt) $divhgt=0;
else $divhgt=Max(1,$ ohgt/$maxhgt);
if($divwdt>=$di vhgt) {
$newwdt=$maxwdt ;
$newhgt=round($ ohgt/$divwdt);
} else {
$newhgt=$maxhgt ;
$newwdt=round($ owdt/$divhgt);
}
$tn=imagecreate truecolor($neww dt,$newhgt);
if($quality)
imagecopyresamp led($tn,$img,0, 0,0,0,$newwdt,$ newhgt,$owdt,$o hgt);
else
imagecopyresize d($tn,$img,0,0, 0,0,$newwdt,$ne whgt,$owdt,$ohg t);
imagedestroy($i mg);
$img = $tn;
return array($newwdt, $newhgt);
}
?>
just use the function create thumb to set the dimensions and the
destination file
*There is a script that will work out the % size for you on php.net, if
you need %s*
On Oct 30, 5:19 pm, "jason.ta...@gm ail.com" <jason.ta...@gm ail.com>
wrote:
I was wondering if anyone does any uploading picture scripts or how to
do it where i could upload a picture and use php to change the picture
size to what i want it to be. Anyone know where i could learn how to do
this or have any script examples? i would really appreciate it alot.
thanks for you time
jason