index.html I am submitting this form using ajax and i want all form post data in controller to submit form in database.But its not working.
<form id="uploadproImage" enctype="multipart/form-data">
<div class=" form-group">
<label>Select Image</label>
<input type="file" name="product_file" multiple />
<span class="help-block">Allowed File Size - 1MB MAX.</span>
<span class="help-block">Allowed File Type - webp.</span>
</div>
<button type="submit" name="btnupload">Upload</button>
</form>
main.js
$('#uploadproImage').on('submit', function (e) {
e.preventDefault();
$.ajax({
type: 'POST',
url: 'appcode/product.php',
data: new FormData(this),
dataType: 'json',
contentType: false,
cache: false,
processData: false,
beforeSend: function () {
},
success: function (response) {
alert(response);
// if (response.status == 1) {
// $('#uploadproImage')[0].reset();
// alert(response);
// } else {
// alert(response);
// }
}
});
});
product.php
if(isset($_POST['btnupload'])){
if(!empty($_FILES["product_file"]["name"])){
}else{
echo 'File Not Selected';
}
}else{
echo 'Sorry, there was an error uploading your file.';
}
Output: 'Sorry, there was an error uploading your file.'
But I Want To 'File Not Selected'