The code below uploads images to my sql database called upload_image
.
if(isset($_POST['submit'])){
$target_path = "images/";
$target_path = $target_path . basename($_FILES['file']['name']);
if(move_uploaded_file($_FILES['file']['tmp_name'], $target_path)){
$conn =new mysqli("localhost", "root", "", "upload_image");
$sql = "Insert into upload_image('path') values('$target_path')";
if($conn->query($sql)==TRUE){
echo"<br><br>";
}else{
echo "Error on upload".$sql.$conn->error;
}
}
}
The error being displayed is
Error on uploadInsert into upload_image('path') values('images/ao.png')
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''path') values('images/ao.png')' at line 1
Here is the HTML part:
<form method="post" enctype="multipart/form-data">
<input type="hidden" value=="1000000" name="MAX_FILE_SIZE"/>
<input type="file" name="file"/>
<input type="submit" name="submit" value="Upload"/>
The HTML and PHP are all in one code.