I selected a image using:
<input type="file" id="pimg" name="pimg" accept='image/*'/>
My javascript code:
p_img =document.getElementById("pimg").value;
param= 'pn='+p_img;
xmlhttp.open("GET","add_prod.php?"+param,false);
xmlhttp.send();
My php code:
p_img=$_GET['img'];
$con = mysqli_connect('localhost', 'admin', 'admin', 'products');
$sql="INSERT INTO prod (img) VALUES ('$p_img')";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
This will store only the name of the file. But i want to copy the file from pc to directory. Its necessary to use Javascript as I'm using complete add product to pass values using AJAX