| The original NP Emo Kid Name: Liam Dawe Location: Plymouth, UK Join Date: Jan 2005
Posts: 1,563
NP$: 96.00 ( Donate)
| [PHP] image uploading I currently have this which works pretty dam well.
Although i want to allow more than just jpg files to be uploaded, i also want the names to be proper randomized as right now it keeps the same name so there could be many conflicts PHP Code: $imagename = $_FILES['new_image']['name'];
$source = $_FILES['new_image']['tmp_name'];
$target = "images/uploads/".$imagename;
move_uploaded_file($source, $target);
$imagepath = $imagename;
$save = "images/uploads/" . $imagepath; //This is the new file you saving
$file = "images/uploads/" . $imagepath; //This is the original file
list($width, $height) = getimagesize($file) ;
$diff = $width;
$save = "images/uploads/thumb_" . $imagepath; //This is the new file you saving
$file = "images/uploads/" . $imagepath; //This is the original file
list($width, $height) = getimagesize($file) ;
$tn = imagecreatetruecolor(150, 150) ;
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, 150, 150, $width, $height) ;
imagejpeg($tn, $save, 100) ;
$sql = "UPDATE `listings` SET `screenshot` = '{$imagepath}', `thumbnail_screenshot` = 'thumb_{$imagepath}' WHERE `scriptid` = '{$_GET['lid']}'";
mysql_query($sql);
__________________
**Follow Sig Rules** No references to adult sites!
|