Can't Send File With Ajax To Php File
I am having a problem with receiving File Data. This is my HTML FORM: As you can see it sends us to the file General.js and the php page that need to recieve this: $fileName = $_
Solution 1:
Try using this...
$(document).ready(function (e) {
$("#Form").on('submit',(function(e) {
e.preventDefault();
$.ajax({
url: "uploader.php", // Url to which the request is send
type: "POST", // Type of request to be send, called as method
data: new FormData(this), // Data sent to server, a set of key/value pairs (i.e. form fields and values)
contentType: false, // The content type used when sending data to the server.
cache: false, // To unable request pages to be cached
processData:false, // To send DOMDocument or non processed data file it is set to false
success: function(data) // A function to be called if request succeeds
{
console.log(data);
}
});
}));
});
Solution 2:
change
var formData = new FormData(document.getElementById('Form'));
to
var fd = new FormData();
fd.append("userfile", document.getElementById('userfile').value);
Post a Comment for "Can't Send File With Ajax To Php File"