Hello,
Searching in experts-exhange answers I found the php part of the following code(and modify it a bit):
$tpath = "C:/AppServ/www/personal_w
ebsite/03/
resize/upl
oads";//th
umbnails path
//check for uploaded file from form
if ($_FILES['image1'] != "") {
//name of uploaded image selected from form
$img = $_FILES['image1']['tmp_nam
e'];
//name for created thumbnail
$img_name = $_FILES['image1']['name'];
$dimensions = GetImageSize($img);
$thname = "$tpath/$img_name";
$w=$dimensions[0];
$h=$dimensions[1];
$img2 = ImageCreateFromJPEG($img);
//set new proportional height $nh and width $nw
//if image is wider than it is tall
if ($w < $h){
$nw = 100;
$nh = $h * $nw / $w;
$sw = 0;
$sh = ($nh/2)-50;
}
//if image is taller than it is wide
if ($w > $h){
$nh = 100;
$nw = $w * $nh / $h;
$sh = 0;
$sw = ($nw/2)-50;
}
//if image is square
if ($w == $h){
$nw = 100;
$nh = 100;
$sw = 0;
$sh = 0;
}
$thumb = imagecreatetruecolor(100,1
00);
$thumb1 = imagecreatetruecolor($nw,$
nh);
ImageCopyResampled($thumb1
,$img2,0,0
,0,0,$nw,$
nh,$w,$h);
imagecopyresized ($thumb, $thumb1, 0, 0, $sw, $sh, 100, 100, 100, 100);
ImageJPEG($thumb,$thname,9
0); //stores thumbnail
imagedestroy($img2);
//store the full-size image
copy($_FILES['myfile']['tm
p_name'], "C:/AppServ/www/personal_w
ebsite/03/
resize/upl
oads".$_FI
LES['myfil
e']['name'
])
or die("Couldn't copy the full-size file!");
} else {
die("No input file specified");
}
}
?>
<html>
<head>
</head>
<body>
<form action="resize.php" method="post" enctype="multipart/form-da
ta">
Select file to upload:
<input type="file" name="image1" />
<input type="hidden" name="submit_img" value="1" />
<input type="submit" name="submit" value="submit" />
</form>
</body>
</html>
I have a directory called uploads and there I want to store the uploaded files (not-edited). I also have a directory called thumbs(inside uploads) where I want to store the edited images. Also I want to be able to adjust the crop, resize dimensions dynamically with some text fields asking the user to put the new image dimensions instead from having to edit the php file
Can you provide a complete php code for the above?