Reputation: 11
I have an img tag
<img data-bind="attr: { src: imageUrl() }" />
I binded it to imageUrl()
function in knockoutjs.
self.imageUrl = ko.computed(function () {
return "C:/Users/FC/Desktop/54f46f4613ba6106000d98f7.jpg";
});
And I have an image that has JPEG format in my desktop.
Url is correct but I can not show this image on page. It can not be displayed.
What's problem?
Upvotes: 0
Views: 61
Reputation: 2258
you're missing the file protocol:
return "file://C:/Users/FC/Desktop/54f46f4613ba6106000d98f7.jpg"
still, you shouldn't be serving up resources from the local filesystem. consider using a webservice.
Upvotes: 1
Reputation:
Javascript cannot access your filesystem. Put the image where the webserver can see your assets and reference it by URL.
Upvotes: 1