Noobprogramer
Noobprogramer

Reputation: 21

How do I make my Html Image Source from a file path?

I am trying to insert an image from my computer into my HTML page (hopetnorman.pythonanywhere.com) and it's not working. Here is the code:

<img src="C:\Users\Alan\Downloads\Thomas Logo\Dogo.jpg" height="50px" class="Barpic">

Anybody know why?

Upvotes: 2

Views: 396

Answers (3)

Noobprogramer
Noobprogramer

Reputation: 21

I figured out a way - I posted it on imgur then copied the image address from there.

Upvotes: 0

Rayon
Rayon

Reputation: 41

Maybe the best way will be if you put your image into folder where you have your html file then:

<img src="Dogo.jpg" height="50px" class="Barpic">

Or make another folder in folder where your html is for all your images:

<img src="folderWhereIhaveHTML/folderForImages/Dogo.jpg" height="50px" class="Barpic">

Upvotes: 0

Kagemaru
Kagemaru

Reputation: 21

It sounds to me, like you're trying to put a local file into a hosted page. This would not work, because the hosted page does not know where "C:\" is.

For it to work on a hosted website, you need to upload it from your computer to the page, or at a service that hosts your pictures and use the path to that online picture to your html site.

It would need to look something like this:

<img src="http://hopetnorman.pythonanywhere.com/Thomas%20Logo/Dogo.jpg" height="50px" class="Barpic" />

Or if the picture lies in the same folder as your page.

<img src="./Dogo.jpg" height="50px" class="Barpic" />

Also for code posts, there is a button "{}" while editing.

Upvotes: 2

Related Questions