0
I did the code in ajax to send information through the click method, but the file does not arrive in the email, only the other data, in the Console appears the array with file type, size, name, everything right but not working... I don’t know how to insert the php snippet here, but sending the form directly by php works, so the error can only be in the treatment of the ajax file
$("#enviar").click(function() {
var form_data = new FormData();
var file_data = $("#image1").prop("files")[0];
form_data.append("#image1", file_data);
form_data.append("nome_completo", $("#nome_completo").val());
var settings = {
"url": "curriculo.php",
"method": "POST",
"processData": false,
"contentType": false,
"data": form_data
}
$.ajax(settings).done(function(response) {
console.log(response);
});
});
<form id="msform" method="post" action="send.php" enctype="multipart/form-data">
<div class="col-md-4 form-group">
<label>Nome Completo*</label>
<input id="nome_completo" name="curriculo[nome_completo]" minlength="5" type="text" class="form-control" placeholder="Nome Completo*">
</div>
<div class="row">
<div class="col-md-12">
<div class="browse-wrap">
<div class="title">Anexar Currículo</div>
<input type="file" id="image1" name="image1" class="upload" title="Anexar Currículo">
</div>
<span class="upload-path"></span>
</div>
</div>
</form>
What would be the difference between this question and this one? https://answall.com/questions/312012/enviar-input-file-por-ajax
– Sam
The code is completely modified, easier to identify the problem in this one, I tried to delete the previous one
– Jvs Corrêa
You could edit the other one without having to duplicate the question.
– Sam
Because the
contentType : false
?– reisdev
@Matheusreis when I tried to use another term the data did not go to php, only it in false I started to receive the right, less the file
– Jvs Corrêa
Take a look in that matter
– reisdev
I’m going to ask the same question as the previous question you asked and you have the same problem. Can you post a complete and verifiable example? With the code posted you can’t reproduce the problem. Nor does the clickable element have in the question code. If you want an answer avoid giving work to anyone who wants to solve your problem. If you have any questions, read this post https://answall.com/help/mcve
– user60252
Resume and send page code?
– user60252
It was a typo in the code. Thank you all!
– Jvs Corrêa