i used to do this by uploading the image to the database but later learned its the wrong way because when you try to export the database if ur moving it from localhost to the server the images dont come along :( so anywho, the script i have here is to get the image , crop it, give it a random name and drop it into the gallery folder. but for some reason its not working, and i cant figure it out.. if someone can help me
thanks
if(isset($_POST['submit']) && $_FILES['galleryimg']['size'] > 0) {
$tmpname = $_FILES['galleryimg']['tmp_name'];
$imgsize = $security->secure($_FILES['galleryimg']['size']);
$imgtype = $security->secure($_FILES['galleryimg']['type']);
//crop image
$canvas = imagecreatetruecolor(219,127);
$imgattrib = getimagesize($tmpname);
$source = imagecreatefromjpeg($tmpname);
imagecopyresized($canvas,$source,0,0,0,0,219,127,$imgattrib[0],$imgattrib[1]);
$name = rand(1234,43211234).".png";
ob_start();
imagepng($canvas);
//$image = ob_get_contents();
imagepng($canvas,'/uploads/gallery/'.$name);
ob_end_clean();
}
btw, once the images are uploaded how do i read the folder to display the images?