Last active
April 20, 2018 22:25
-
-
Save parzibyte/8eb42dd5218d8d214825f1ad2348de36 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
var $fotoAlumno = $("#fotoAlumno"), | |
$btnGuardar = $("#guardarImagen"); | |
$btnGuardar.click(function() { | |
var archivos = $fotoAlumno[0].files; | |
if (archivos.length > 0) { | |
var foto = archivos[0]; //Sólo queremos la primera imagen, ya que el usuario pudo seleccionar más | |
var lector = new FileReader(); | |
//Ojo: En este caso 'foto' será el nombre con el que recibiremos el archivo en el servidor | |
formData.append('foto', foto); | |
$.ajax({ | |
url: "htpp://localhost/la/ruta/de/nuestro/controlador", | |
data: formData, | |
type: 'POST', | |
contentType: false, | |
processData: false, | |
success: function(resultados) { | |
console.log("Petición terminada. Resultados", resultados); | |
} | |
}); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment