Loading an image to localStorage and setting an image src to that location

后端 未结 1 1369
花落未央
花落未央 2020-12-29 15:17

I\'ve successfully allowed for a user to upload an image to local storage but I want to be able to then take that image and fill an image element on the page with that.

相关标签:
1条回答
  • 2020-12-29 16:15

    Well you can store the actual image data in localStorage (though be wary - there's a limit)

    Have a look at the HTML5 rocks tutorial & scroll down to the bit headed READING FILES

    Here the file is being read then the output put in the img:src tag. You could additionally put it in localStorage

    Example: http://jsfiddle.net/8V9w6/ - select an image file, see the thumbnail? Then reload the page. The thumbnail should remain there. (Works latest Chrome/Firefox)

    0 讨论(0)
提交回复
热议问题