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

135
Vistas
Using XMLHttpRequest upload files (Website is working on most browsers but doesn't work on iOS mobile phone)

I am using XMLHttpRequest to upload images to our server, and it works fine on (Firefox, Chrome, and Safari) when using a desktop and laptop.

When using iPhone to upload images, it failed without errors. The following is my upload function, and I am struggling with many hours please help. Thank you very much.

function ajaxFileUpload() 
 {

    var form = $('#imageform');
    files = form.find('[type="file"]');           

    if (files.length == 0) { 
       return;
    }


    var url = form.prop("action") 
    $('#loading').show();

    fileSelect = form.find('[type="file"]');
    
    var files = fileSelect[0].files;
    var fd = new FormData();
    for (var i = 0; i < files.length; i++) {
         var file = files[i];
         
         //remove deleted images from previous start
         var is_img_removed = false;
         for (j=0; j<imgList_removed.length; j++) {
            if (imgList_removed[j] == file.name) {
                is_img_removed = true;
                break;
            }
         }
         
         if (is_img_removed == true) {
            continue;
         }
         
         //remove deleted images from previous end
         fd.append('fileToUpload', file);
    }
    
    var xhr = new XMLHttpRequest();
    xhr.addEventListener('readystatechange', function(e) {
        if( this.readyState === 4 ) {
            form.find(":file").val("");
            alert('upload successfully');
        }
    });    
 
    xhr.open("POST", url, true);
    xhr.setRequestHeader('Accept-Encoding', 'multipart/form-data'); 
    
    xhr.send(fd);

    return false;
  }
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