Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

180
Vistas
Is there any way to send a file trough an array via AJAX?

I filled up an array with a lot of information(80+variables) and 1 file.

var ArrayEnv= {LOTS OF VARIABLES DECLARED + 1 File}
console.log(ArrayEnv); -> Just for testing purposes

$.ajax({
   url: 'controller/send_data',
   data: ArrayEnv,
   type: 'POST',
   cache: false,
   contentType: false,
   processData: false,
   before:  '',
   success: function(data) {
   console.log('Ajax Value: '+data);
}}); 

So, when I send the data to the controller without the FILE, everythin goes right, but whenever I send a file it crashes. I dont want to use formData since im getting and validating multiple variables through branchings on the JS.

I've done a lot of research and im really losing hope... is there any way to send a file in the same array that containts the data?


Update:

Actually had to use formData to make it work

   data = new FormData($("#validatedForm")[0]);

   $.ajax({
       url: 'controller/send_data',
       data: data,
       cache: false,
       contentType: false,
       processData: false,
       beforeSend: function() {
         console.log('Load');
     },
       method: 'POST',
      // type: 'POST', // For jQuery < 1.9
       success: function ( data ) {
           console.log( data );
       }
   });
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda