I am trying to upload images into my database table called tbl_images and to my images folder saved in the same folder as my source files! i am receiving the error "Parse error: syntax error, unexpected '$imagename' (T_VARIABLE) in"
Here is my index.php code
<!DOCTYPE html>
<html>
<head>
<title>Index</title>
</head>
<body>
<form action="saveimage.php" method="post" enctype="multipart/form-data">
<h2>Please click on Upload button</h2>
<input type="file" name="uploadedimage">
<input type="submit" name="Upload Image" value="Upload Image">
</form>
</body>
</html>
Here is saveimage.php file. Not sure what the problem is here. Any help is appreciated.
<?php
include ("connection.php");
function GetImageExtension($imagetype)
{
if(empty($imagetype)) return false;
switch($imagetype)
{
case 'image/bmp':return '.bmp';
case 'image/gif':return '.gif';
case 'image/png':return '.png';
case 'image/jpeg':return '.jpeg';
default: return false;
}
}
if(!empty($_FILES["uploadedimage"]["name"]))
{
$file_name=$_FILES["uploadedimage"]["name"];
$temp_name=$_FILES["uploadedimage"]["tmp_name"];
$imgtype=$_FILES["uploadedimage"]["type"];
$ext=GetImageExtension($imgtype)
$imagename=date("d-m-Y")."-".time().$.$ext;
$target_path="images/".$imagename;
if(move_uploaded_file($temp_name, $target_path))
{
$query_upload="INSERT into tbl_images
(image_name,submission_date)
values
('".$imagename."','".date("Y-m-d")."')";
mysqli_query($con,$query_upload);
echo "Image has been uploaded";
}
}
else {
echo "Can not upload image";
}
?>