I have form submited with Ajax I can't upload image in this submit
<form id="forms-items" name="forms-items" method="post" enctype="multipart/form-data">
<input id="uploadBtn" name="uploadimg" type="file" class="upload" />
</form
in submit code
if($_FILES['uploadimg']['size']>0)
{
$ftype=$_FILES["uploadimg"]["type"];
if(move_uploaded_file($_FILES['uploadimg']['tmp_name'], $target_path))
{
$default=1;
$mesg="File Uploaded Successfully";
}
else
$mesg="File Uploading Failed!!";
else
$mesg="Please Select A File";
The output: Please Select A File
JavaScript code
$("#forms-items").submit(function()
{
$.ajax({
url: "ajax/submitform.php",
type: "POST",
data: $("#forms-items").serialize(),
success: function(response) {
alert(response);
}
});
});
See Question&Answers more detail:os