วิธีอัพโหลดรูปแล้วมีลายน้ำ

$watermarkImagePath = 'img/logo-s.png'; 
//$fileName = basename($_FILES["file"]["name"]); 
$targetFilePath = "upload/" . $newfilename; 
$fileType = pathinfo($targetFilePath,PATHINFO_EXTENSION);  
if(move_uploaded_file($filetemp,$targetFilePath)){ 
	// Load the stamp and the photo to apply the watermark to 
	$watermarkImg = imagecreatefrompng($watermarkImagePath); 
	switch($fileType){ 
		case 'jpg': 
			$im = imagecreatefromjpeg($targetFilePath); 
			break; 
		case 'jpeg': 
			$im = imagecreatefromjpeg($targetFilePath); 
			break; 
		case 'png': 
			$im = imagecreatefrompng($targetFilePath); 
			break; 
		default: 
			$im = imagecreatefromjpeg($targetFilePath); 
				} 

	// Set the margins for the watermark 
	$marge_right = 10; 
	$marge_bottom = 10; 

	// Get the height/width of the watermark image 
	$sx = imagesx($watermarkImg); 
	$sy = imagesy($watermarkImg); 

	// Copy the watermark image onto our photo using the margin offsets and  
	// the photo width to calculate the positioning of the watermark. 
	imagecopy($im, $watermarkImg, (imagesx($im) - $sx)/2, (imagesy($im) - $sy)/2, 0, 0, imagesx($watermarkImg), imagesy($watermarkImg)); 

	// Save image and free memory 
	imagepng($im, $targetFilePath); 
	imagedestroy($im); 
}