<?php include('header.php');
include ('config.php');
if(isset($_POST['submit_image'])){
$imgname=$_FILES["myimage"]["name"] ;
$target="ProfileImages/";
$filetarget=$target.$imgname;
$tempname=$_FILES["myimage"]["tmp_name"];
$result = move_uploaded_file($tempname,$filetarget);
if($result){
$id=$_SESSION['id'];
$caption=$_POST['caption'];
$q="INSERT into `images` (id,path,caption) VALUES ('$id','$filetarget','$caption')";
$res=mysqli_query($con,$q);
if($res)
{
$msg="Photo Uploaded Sucessfully..";
$_SESSION['msg']=$msg;
header('location:profile.php');
}
}
else{
$msg="Error Not Uploaded...Try Again";
$_SESSION['msg']=$msg;
header('location:profile.php');
}
}
?>
<form method="POST" enctype="multipart/form-data">
<h2><u>Select Image</u></h2><br><input type="file" name="myimage"><br>
<h2><u>Caption</u></h2><br>
<textarea rows="4" cols="25" name="caption"></textarea>
<input type="submit" name="submit_image" value="Upload">
</form>
Heading
I was trying to upload pictures through this code, but after some time I checked it was not working...Can any of you help me how to fix this?