Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing LocalFileSystem to store and display images
    primarykey
    data
    text
    <p>I tried to write a bit of code to retrieve an image file (from Wikimedia Commons), store it locally and then display it. Here my code:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;script&gt; window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem; function onError(e) { console.log('Error', e); } var xhr = new XMLHttpRequest(); xhr.open('GET', 'http://upload.wikimedia.org/wikipedia/fr/2/26/10_francs_Mathieu_1987_F365-28_revers.jpg', true); xhr.responseType = 'blob'; xhr.onload = function(e) { window.requestFileSystem(PERSISTENT, 1024 * 1024, function(fs) {alert(fs.root.name);}, onError); window.requestFileSystem(PERSISTENT, 1024 * 1024, function(fs) { fs.root.getFile('image.jpg', {create: true}, function(fileEntry) { fileEntry.createWriter(function(writer) { writer.onwrite = function(e) {}; writer.onerror = function(e) {}; var blob = new Blob([xhr.response], {type: 'image/jpeg'}); writer.write(blob); }, onError); }, onError); }, onError); window.requestFileSystem(PERSISTENT, 1024 * 1024, function(fs) { fs.root.getFile('image.jpg', {create: false}, function(fileEntry) { fileEntry.file(function(file) { var reader = new FileReader(); reader.onloadend = function(event) { var img = document.createElement("img"); img.src = event.target.result; document.body.parentNode.insertBefore(img, document.body.nextSibling); }; reader.readAsDataURL(file); }, onError); }, onError); }, onError); }; xhr.send(); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Nothing is displayed. Chrome's console doesn't display any error message, so I have no idea why it's not working. Any clue?</p> <p>Edit :</p> <p>I have just seen I actually get a FileError, code 10, which means QUOTA_EXCEEDED_ERR, even if I start my Google Chrome with these parameters:</p> <pre><code>"C:\Program Files\Google\Chrome\Application\chrome.exe" --allow-file-access-from-files --unlimited-quota-for-files </code></pre> <p>Actually, I get the same error with or without the <code>--unlimited-quota-for-files</code> parameter, which is weird. But I get a File Error 2 without <code>--allow-file-access-from-files</code></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload