4
I am trying to receive a PHP image sent through AJAX, but I was not successful. Follow the code:
jQuery:
$("#envmsg").submit(function() {
$("#btn-enviarmsg").button("loading");
$("body").css("cursor", "wait");
var dados = $(this).serialize();
$.ajax({
type: "POST",
url: "/enviamsg.php",
data: dados,
success: function(data) {
document.getElementById("envmsg").reset();
$("#btn-enviarmsg").button("reset");
$("body").css("cursor", "default");
$("#deixarMensagem").modal("hide");
location.reload();
}
});
return false;
});
and in the enviar.php. i do the checking:
if($_FILES["foto"]) {
$foto = echo "<script>alert('tem foto');</script>";
} else {
$foto = echo "<script>alert('n tem foto');</script>";
}
But nothing occore, why?
Note: This form sends some text fields and the image. I just posted snippets of the code related to the problem.
Note: My form is enctype="Multipart/form-data".
Thank you!
Would that not be the same as this question? http://answall.com/questions/29770/
– Bacco
Opa, thank you @Bacco, I had done several searches, but I had not seen the link you gave me. Well, it worked. Thanks.
– Igor
Anyway, your question will link to each other, increasing the chance of someone with the same problem finding the solution when searching.
– Bacco