我想使用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