arame3333
arame3333

Reputation: 10193

I would like to display images from an absolute path

I would like to store my images in a directory, say

C:/Photos

But to display these images in my application using the img element, I have to use a pathname that is relative to my project directory. For example

<img src="@Url.Content("~/photos/image.jpg")">

Instead of doing that, is there a way I can use an absolute pathname instead, or is it impossible?

Upvotes: 0

Views: 2412

Answers (1)

Happysmithers
Happysmithers

Reputation: 761

You can use absolute path names if you really want, of course. They would start with a single backslash on windows ("\").

In a typical production environment (webserver) you can link to your images with the full http address also in an absolute way:

<img src="https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_120x44dp.png" />

But beware of the problems this may bring when you switch to a different machine etc.

Upvotes: 1

Related Questions