I have an option to upload images with caption for every table and there can be any number of tables.
I am using the script below but alert('qwert') does not popup but instead alert('asdf') popsup.Any ideas?
PHP file1:
<form method='post' enctype='multipart/form-data' class='MyUploadForm'>
<input name='ImageFile' class='imageInput' id='imageInput' type='file'>
<input class='form-control dsa addcaption' name='addcaption' placeholder='Add caption' type='text' >
<input type='submit' class='btn-custom5' value='Upload' >
<button class='btn btn-custom4 imageuploading' name='imageuploading' style='visibility:hidden' value='$x' ></button>//$x will specify path
</form>
<div class='output'></div>
AJAX:
$(document).ready(function() {
var options = {
target: '.output', // target element(s) to be updated with server response
beforeSubmit: beforeSubmit, // pre-submit callback
success: afterSuccess, // post-submit callback
resetForm: true // reset the form after successful submit
};
$('.MyUploadForm').submit(function() {
$(this).ajaxSubmit(options);
return false;
});
});
function beforeSubmit(){
alert('qwert');
//code to check conditions for file type and size
}
PHP file2:
if(isset($_POST))
{
//check if this is an ajax request
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH'])){
die("<script> alert('asdf')</script>");
}
}