Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. $(document).ready(function() {
  2. // hice el submit desde un botón,
  3. // para que sea más fácil saber cuando se hayan agregado otros files
  4. $('#submit').on('click', function(e) {
  5. e.preventDefault();
  6.  
  7. var fileName = $(this)
  8. .val()
  9. .split('\')
  10. .pop();
  11. // obtenemos los input file con la clase '.file-upload'
  12. var $inputsFile = $('.file-upload');
  13. var formData = new FormData();
  14. $inputsFile.each(function(index) {
  15. // hacemos el append a formData
  16. formData.append('file' + index, $(this)[0].files[0]);
  17. });
  18.  
  19. $.ajax({
  20. url: '/script/Guardar_Archivos.ashx',
  21. type: 'POST',
  22. data: formData,
  23. cache: false,
  24. contentType: false,
  25. processData: false,
  26. success: function() {
  27. alert('Archivo subido con exito');
  28. },
  29. error: function(err) {
  30. alert(err.statusText);
  31. }
  32. });
  33. });
  34. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement