g3mma111 Posted December 13, 2007 Share Posted December 13, 2007 I have this script which resizes an uploaded picture, saves it to a folder, and then saves its url to a database. I still want to do this but i also want to keep the original image and save that to a different folder called horiginalpic/ and then save the url of that to the database. If any one could help it would be appreciated. $host = "***************"; $user = "****"; $pass = "******"; $db = "********"; $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); mysql_select_db($db) or die ("Unable to select database!"); $query = "SELECT * FROM members where (username = '$ses_username')"; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); $obj=mysql_fetch_object($result); $hname=$obj->hname; $uploadedfile = $_FILES['uploadfile']['tmp_name']; $src = imagecreatefromjpeg($uploadedfile); list($width,$height)=getimagesize($uploadedfile); $newwidth=100; $newheight=($height/$width)*100; $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); $thumbfilename = "hthumbpic/". $ses_username.$hname. ".jpg"; imagejpeg($tmp,$filename,100); imagedestroy($src); imagedestroy($tmp); $query = " INSERT INTO `".$pics."` ( `username` , `thumburl` ) VALUES ( '".$ses_username."' , '".$thumbfilename."' )"; if(mysql_query($query)){ echo 'Query executed successfully'; } else { echo 'Query failed'; } mysql_close(); Link to comment https://forums.phpfreaks.com/topic/81507-help-with-upload-script/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.