Im trying to make a simple image upload system for my website and i keep gettting this error and i dont know how to fix it! 🙁
Here is my PHP:

<?php
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFiletype = pathinfo($target_file,PATHINFO_EXTENSION);
//Check if image is real or fake
if(isset($_POST["submit"])) {
	$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
	if($check !== false) {
		echo "File is an image - " . $check["mime"] . ".";
		$uploadOk = 1;
	} else {
		echo "File is not an image.";
		$uploadOk = 0;
	}
}
//Check if the file already exists
if (file_exists($target_file)) {
	echo "Sorry, that file already exists.";
	$uploadOk = 0;
}
//Check file size
if ($_FILES["fileToUpload"]["size"] > 500000) {
	echo "Sorry, your file is too large.";
	$uploadOk = 0;
}
//Allow certain formats
if ($imageFileType != "jpg" && $$ $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif") {
	echo "Sorry, only JPG, JPEG, PNG, & GIF files."
	$uploadOk = 0;
}
?>

And here is my HTML:

<!DOCTYPE html>
<html>
<body>
<form action="upload.php" method="post" enctype="multipart/form-data">
	Select Image to Upload:
	<input type="file" name"fileToUpload" id="fileToUpload">
	<input type="submit" value="Upload Image" name="submit">
</form>

</body>
</html>

This is the error i keep getting:
Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in /home/a7281998/public_html/upload.php on line 30

    Don't panic, you merely forgot the terminating semi-colon on this line:

    echo "Sorry, only JPG, JPEG, PNG, & GIF files."

      Thanks, that fix that problem, but now i get this error:
      Warning: getimagesize() [function.getimagesize]: Filename cannot be empty in /home/a7281998/public_html/upload.php on line 8

      File is not an image.Sorry, that file already exists.Sorry, only JPG, JPEG, PNG, & GIF files.

        Write a Reply...