I am trying to save images for an Application to the localFolder with the help of the Winjs.xhr function. This works totally fine, but if I want to put the picture to the src attribute of an image I always get Error DOM7009: Unable to decode image at URL ms-appdata:///local/name.png. I tried it with different images but this error always occures.
Javascript:
var imgUrl = "http://www.microsoft.com/windows/Framework/images/win_logo.png";
WinJS.xhr({
url: imgUrl,
responseType: "blob"
}).then(
function completed(result) {
var newFile = result.response;
var localFolder = Windows.Storage.ApplicationData.current.localFolder;
var fileName = "image.png";
var CreationCollisionOption = Windows.Storage.CreationCollisionOption;
return localFolder.createFileAsync(fileName,CreationCollisionOption.replaceExisting);
}).then(
function createFileSuccess() {
var msgtext = "File downloaded successfully!";
var msg = new Windows.UI.Popups.MessageDialog(msgtext);
return msg.showAsync();
});
HTML:
<img src="ms-appdata:///local/image.png"/>
What am I doing wrong?
Edit: I saw other people also having "the unable to decode" error on Internet Explorer. There the problem seemed to be using very large images. But im only working with icon-sized images, so it seems to be a different problem.
I opened the file, but wrote nothing in it.