I am working on a project to upload images into a directory and store image paths in database table. The image upload work fine but my text input for name is not working. I need your help.
if(isset($_POST['upload']))
{
$path=$path.$_FILES['file_upload']['name'];
if(move_uploaded_file($_FILES['file_upload']['tmp_name'],$path))
{
echo " ".basename($_FILES['file_upload']['name'])." has been uploaded<br/>";
echo '<img src="gallery/'.$_FILES['file_upload']['name'].'" width="48" height="48"/>';
$img=$_FILES['file_upload']['name'];
$query="insert into imgtables (name,imgurl,date) values('$name',STR_TO_DATE('$dateofbirth','%d-%m-%y'),'$img',now())";
if($sp->query($query)){
echo "<br/>Inserted to DB also";
}else{
echo "Error <br/>".$sp->error;
}
}
else
{
echo "There is an error,please retry or ckeck path";
}
}
?>
The form is as follows:
<form action="gallery.php" method="post" enctype="multipart/form-data">
<table width="384" border="1" align="center">
<tr>
<td width="108">Name</td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td width="108">Select File</td>
<td width="260"><label><input type="file" name="file_upload"></label></td>
</tr>
<tr>
<td></td>
<td><label><input type="submit" name="upload" value="Upload File"></label></td>
</tr>
</table>
</form>