Im Grunde habe ich ein type="file"
, ich brauche ausgewählte Datei durch Ajax zu schicken, aber jedes Mal, wenn die Form erhalte ich eine Konsole Fehler vorlegen wird, die sagt:Wie Ajax xhr Fehler beheben in jquery
hier ist, wie ich myform einreichen:
$(document).ready(function() {
$('form').submit(function(event) {
event.preventDefault();
checkforImage($('#Propicselecter_file'), "yes");
});
$('[type="file"]').change(function() {
var fileInput = $(this);
checkforImage(fileInput, "no");
});
});
function submit_form(){
var fileInput = $('#Propicselecter_file');
$.ajax({
url: '../propicuploader',
type: 'POST',
processData: false,
data: fileInput[0],
success: function(data){
}
});
}
function checkforImage(fileInput, submitornot){
if (fileInput.length && fileInput[0].files && fileInput[0].files.length) {
var url = window.URL || window.webkitURL;
var image = new Image();
image.onload = function() {
$("#NotPictureerror_spn").text("");
if(submitornot == "yes"){
submit_form();
}
};
image.onerror = function() {
$("#NotPictureerror_spn").text("Chosen file is not an image, Please Try Again");
};
image.src = url.createObjectURL(fileInput[0].files[0]);
}
}
Vielen Dank im Voraus :)
Wie sieht Ihr Beitrag aus? – user3284463
Mein 'post' enthält eine Datei gewählte Datei' type = "file" 'data – darees