Lazy Looser
Lazy Looser

Reputation: 11

Image can not be displayed on page

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

Answers (2)

dfperry
dfperry

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

user1334319
user1334319

Reputation:

Javascript cannot access your filesystem. Put the image where the webserver can see your assets and reference it by URL.

Upvotes: 1

Related Questions