2017-04-10 1 views
1

J'ai rencontré une limitation étrange de iOS/Safari/Chrome. L'utilisateur peut sélectionner une image et son contenu est collé dans un élément d'entrée.Les images sont tronquées après la définition de la valeur SRC (iOS)

La longueur des deux est inégale. Est-ce une limitation iOS?

L.users.importConfigurations = function(options) { 
    var target = null; 

    this._getInputFileElement = function() { 
    var that = this; 
    fileInput = $('<input type="file" accept="image/*" style="display:none;" capture="camera" />'); 
    fileInput.change(function() { 
     that._handleFiles(fileInput); 
    }); 
    return fileInput; 
    }; 

    this.showFileSelectionDialog = function() { 
    var fileInput = this._getInputFileElement(); 
    fileInput.click(); 
    }; 

    this._handleFiles = function(fileInput) { 
    var files = fileInput[0].files; 
    if (files && files.length) this._readFile(files[0]); 
    }; 

    this._readFile = function(fileInfo) { 
    var that = this; 
    var reader = new FileReader(); 
    reader.onload = function(e) { 
     that._uploadFile(e.target.result); 
    }; 
    reader.readAsDataURL(fileInfo); 
    }; 

    this._uploadFile = function(fileData) { 
    var fbValue = $(options.target).closest('.fileboxframe').find(".fileboxvalue"); 
    if (fbValue && fbValue.length > 0) { 
     alert("Length before: " + fileData.length.toString()); 
     fbValue.attr('src', fileData); 
     alert("Length after (Should be same): " + fileData.length.toString()); 
     alert("Length after (Should be same): " + fbValue.attr("src").length.toString()); 
    } 
    }; 

    this.showFileSelectionDialog(); 
}; 

https://jsfiddle.net/ChristophWeigert/81qu41L5/ 

Répondre