Skip to content

Instantly share code, notes, and snippets.

@rickslayer
Created April 5, 2019 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rickslayer/9841371988c640240746096658c64141 to your computer and use it in GitHub Desktop.
Save rickslayer/9841371988c640240746096658c64141 to your computer and use it in GitHub Desktop.
Send parameteres and Files together Ajax - Enviar parametros e arquivos juntos em requisição
<html>
<input type="file" id="files">
</html>
<script>
$(function(){
$("#files").on('change', function(event)
{
form = new FormData();
form.append('files', event.target.files[0]);
form.append('anotherparam', "teste");
let callBack = $.ajax({
url: 'ajaxcallurl',
data: form,
processData: false,
contentType: false,
type: 'POST',
success: function (data) {
console.log(data);
}
});
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment