0

I cannot seem to add an image in html. I'm using ASP.net MVC 3. My image, named KeyLargoPic, is located on a flash drive in the folder X:\Project\Project\Photos\Key Largo, and it appears to be a JPEG. The code is as follows:

<td><img src="X:\Project\Project\Photos\Key Largo\KeyLargoPic.jpg" alt="IMAGE" /></td>

Every time the page loads, it shows the box with "IMAGE" inside. Does anyone know what I'm doing wrong?

1
  • The image has to be accessible from your webservers document root... this is obviously not the case here. Commented Jul 30, 2013 at 3:56

3 Answers 3

3

Upload the image to your web server and reference via web path from your project. The web server can't read from your usb drive.

Sign up to request clarification or add additional context in comments.

Comments

1

Try to mount a virtual directory in IIS pointing to X:\Project[...] so you will be able to access your ressources with a relative address

Comments

0

Add the image to your project, probably in the content directory, by right clicking the directory and clicking "Add" then "Existing Item", browse to your jpeg and click "Add". With your image now part of the project you can add it to the webpage like so:

<td><img src="@Url.Content("~/Content/KeyLargoPic.jpg")" alt="IMAGE"></td>

2 Comments

It depends what you're after, if it's images you just need to display on the website like logos ect then follow the above method for all of your images. If you looking to allow people to upload like profile pictures you might want to think about storing them in a database.
It's the latter case, and the plan is to store the address in the DB and the files on a hard disk.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.