this is my ajax code
var fd = new FormData();
fd.append( 'file', $('#img')[0].files[0]);
var data = '&com='+company+'&loc='+location+'&year='+year+'&desc='+des+'&userid='+userid+'&fd='+fd;
$.ajax({
type : "POST",
url: "insert.php",
data : data,
success: function (response){
}
});
this is php code
$conn =new mysqli("localhost", "root", "","test2");
$company=isset($_POST['com']) ? $_POST['com']: '';
$local=isset($_POST['loc']) ? $_POST['loc']: '';
$year=isset($_POST['year']) ? $_POST['year']: '';
$description=isset($_POST['desc']) ? $_POST['desc']: '';
$userid=isset($_POST['userid']) ? $_POST['userid']: '';
$query = mysqli_query($conn,"call exp('$userid', '$company', '$local', '$year', '$description')");
$target = "C:/xampp/htdocs/img/";
$target = $target . basename( $_FILES['file']['name']);
$Filename=basename( $_FILES['file']['name']);
if(move_uploaded_file($_FILES['file']['tmp_name'], $target)) {
$conn =new mysqli("localhost", "root", "","test2");
$query = mysqli_query($conn,"INSERT INTO experience (image , PersonID) VALUES ('$Filename','$userid')");
print_r($query);
} else {
echo "Sorry, there was a problem uploading your file.";
}
how to send param and image in ajax ....As i can send only image separately and data separately in data . as i have try many different code but not working perfectly