Olá a todos!
Preciso de desenvolver um script que faça upload de imagens e depois as watermark. Comecei com o seguinte:
No entanto, dá me o seguinte erro:
Parse error: syntax error, unexpected T_STRING, expecting ']' in C:\xampp\htdocs\try.php on line 14
Muito obrigado a todos os que me puderem responder
Preciso de desenvolver um script que faça upload de imagens e depois as watermark. Comecei com o seguinte:
Código:
<?php
$target_path = "images/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
$imagesource = $_SERVER['images/basename( $_FILES['uploadedfile']['name'])'] . "/" . $_GET['path'];
if (!file_exists($imagesource)) die(Your image upload wasn't successfully completed);
$filetype = strtolower(substr($imagesource,strlen($imagesource)-4,4));
if($filetype == ".gif") $image = @imagecreatefromgif($imagesource);
if($filetype == ".jpg") $image = @imagecreatefromjpeg($imagesource);
if($filetype == ".png") $image = @imagecreatefrompng($imagesource);
if (empty($image)) die();
$watermark = @imagecreatefromgif('watermark.gif');
$imagewidth = imagesx($image);
$imageheight = imagesy($image);
$watermarkwidth = imagesx($watermark);
$watermarkheight = imagesy($watermark);
$startwidth = (($imagewidth - $watermarkwidth)/2);
$startheight = (($imageheight - $watermarkheight)/2);
imagecopy($image, $watermark, $startwidth, $startheight, 0, 0, $watermarkwidth, $watermarkheight);
header("Content-type: image/jpeg");
imagejpeg($image);
imagedestroy($image);
imagedestroy($watermark);
?>
Sendo o form html:
<form enctype="multipart/form-data" action="try.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
Parse error: syntax error, unexpected T_STRING, expecting ']' in C:\xampp\htdocs\try.php on line 14
Muito obrigado a todos os que me puderem responder
Última edição pelo moderador: