0
I have the following code:
HTML:
<input type="file" name="image[]" class="selecao_arquivo" id="selecao_arquivo" multiple>
Javascript:
sendInsucesso.addEventListener('click', e => {
e.preventDefault()
const files = document.querySelector('.selecao_arquivo')
var formData = new FormData(formInsucesso)
for (let i = 0; i < files.length; i++) {
formData.append(files[i].name, files[i])
}
fetch('library/fetch/fetch_form_insucesso.php', {
method: 'POST',
body: new URLSearchParams(formData)
})
.then(response => response.text())
.then(response => console.log(response))
.catch(error => console.error(error))
})
With send to the PHP however, I receive data from files like [Object File].
formData.append(files[i].name, files[i].files[0]), try this
– Rogerio Santos
@Rogeriosantos paid for the tip, but I still have the same problem brother, I’m looking for other solutions, but it’s hard!
– Maykel Figueiredo