I am trying to update an upload image to folder using php file upload and could not get the previously occured image in the database. Here is my code,problem is I could not get the previous image in the file upload section from database. Please help.
if(isset($_GET['msg']))
{
echo $_GET['msg'];
}
$id=(isset($_GET['id']))?$_GET['id']:'';
$val=view_data1_event($id);
if (isset($_POST["events"])&&isset($_POST["description"]))
{
$id=$_POST["id"];
$title=$_POST["events"];
$description=$_POST["description"];
$filetmp=$_FILES["images"]["tmp_name"];
$filename=$_FILES["images"]["name"];
$filetype=$_FILES["images"]["type"];
$filepath= "photo2/".$filename;
move_uploaded_file( $filetmp,$filepath);
$update1=update_query($title,$description,$filename,$filepath,$id);
if($update1)
{
echo "<script>location.href='hotel1_galery_event.php'</script>";
}
}
HTML
<form action="hotel2_galery_eventedit.php" method="post" class="col-sm-4" enctype="multipart/form-data">
<div class="form-group has-info">
<label>Event Related images</label>
<input type="file" name="images">
<input type="hidden" name="image_name" value="<?php echo $val->image_name?>">
<input type="hidden" name="image_path" value="<?php echo $val->image_path?>">
</div>
<button type="submit" class="btn btn-primary">
<span>UPDATE</span>
</button>
</form>
Your form method is post
and you are using as get
in php.
Please replace all GET
with POST
if(isset($_GET['msg']))
This should be,
if(isset($_POST['msg']))