-1
Form:
<form id="form" enctype="multipart/form-data">
<input type="file" name="arquivo" multiple/>
<br>
<br>
<input type="submit" id="linkTest" value="Consultar">
</form>
Ajax:
<script type="text/javascript">
$("#linkTest").on('click', function(e){
e.preventDefault();
var form = $('form')[0];
var formData = new FormData(form);
$.ajax({
type: 'post',
url: 'upload.php',
data: 'formData',
proccessData: false,
contentType: false,
success: function (data) {
alert(data);
}
});
});
</script>
PHP:
<?php
$arquivo = $_FILES['arquivo'];
?>
Tip: Switch the event from the button to the form’s Submit event. This TB will make it easy to grab the data and submit.
– tvdias
You are sending a string and not the formData object. Remove the date quotes: 'formData'
– tvdias
TB there is that example, which is exactly what you want to do.
– tvdias
I removed the quotation marks and agr n receive no more answer. I will look at this article q showed me
– Anderson
The problem was in "proccessData: false," the right one would be: "processData: false,"
– Anderson
And it even works with form data as string?
– tvdias
In this case, add a reply and mark it as accepted. Highlight the problem in the typo.
– tvdias
And the question should be closed, because it is only a typo.
– tvdias
No! only after correcting the quotation marks and then correct the "proccessData: false," to "processData: false,".
– Anderson