Ver Mensaje Individual
  #4 (permalink)  
Antiguo 04/01/2016, 10:48
Zenok
 
Fecha de Ingreso: diciembre-2015
Ubicación: Valencia
Mensajes: 61
Antigüedad: 8 años, 4 meses
Puntos: 10
Respuesta: Subir una imagen al servidor con ajax

Como te han comentado, necesitas utilizar el formdata

Prueba con esto

Código Javascript:
Ver original
  1. $(document).on('click', '#send', function(e)
  2.                 {
  3.                     var data = new FormData();
  4.                     var input = $('#photos');
  5.                     //Append files infos
  6.                     $.each(input[0].files, function(i, file) {
  7.                         data.append('file-'+i, file);
  8.                     });
  9.                    
  10.                      $.ajax({  
  11.                         url: "test.php",  
  12.                         type: "POST",  
  13.                         data: data,  
  14.                         cache: false,
  15.                         processData: false,  
  16.                         contentType: false,
  17.                         context: this,
  18.                         success: function (msg) {
  19.                              alert(msg);
  20.                          }
  21.                      });
  22.                     e.preventDefault();
  23.                 });
  24.             });

Código HTML:
Ver original
  1. <form method="post" action="" id="form-upload" enctype="multipart/form-data">
  2.             <input type="file" id="photos" name="photos[]" multiple/>
  3.             <input type="submit" id="send"/>
  4.         </form>