我想使用jquery将本地存储配置文件图像上传和存储(为了一个演示目的)。我只是上传部分,不知道如何将该图像存储在本地存储中。请检查这fiddle并帮助我解决这个问题。谢谢。如何使用jquery在本地存储中存储配置文件图像
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function(e) {
$('#bannerImg').attr('src', reader.result);
}
reader.readAsDataURL(input.files[0]);
}
}
$(".file-upload").change(function() {
readURL(this);
});
$(".upload-button").on('click', function() {
$(".file-upload").click();
});
图像转换为base64可能会帮助你,http://stackoverflow.com/questions/19017401/how-to-store-and-retrieve-image-to-localstorage – M98