loading image from computer to browser

  • (2 Pages)
  • +
  • 1
  • 2

26 Replies - 4101 Views - Last Post: 08 February 2012 - 07:31 AM

#1 bita  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 190
  • Joined: 21-April 09

loading image from computer to browser

Posted 07 February 2012 - 12:52 PM

Hi guys,

I have a problem with loading an image from my computer. The following code is what I wrote, and the path for the image,the name of the image, and the format of it(JPEG) are all correct. but it doesn't work and just show me the 'sth' which I wrote in 'alt'.
What could be wrong with it?

<html>
<body>

<h1>This is my rabbit</h2>
<img src="C:\Users\Sophia\Desktop\html\sophia.JPEG" alt="sth" width="600",height="700" />

</body>
</html>


Thanks in advance.

Is This A Good Question/Topic? 0
  • +

Replies To: loading image from computer to browser

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3392
  • View blog
  • Posts: 9,586
  • Joined: 08-June 10

Re: loading image from computer to browser

Posted 07 February 2012 - 12:56 PM

first there shouldnít be the comma and Iím not sure if itís a good idea to have the image path absolute to the local file system and not relative (or absolute) to the host.
Was This Post Helpful? 1
  • +
  • -

#3 bita  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 190
  • Joined: 21-April 09

Re: loading image from computer to browser

Posted 07 February 2012 - 01:29 PM

View PostDormilich, on 07 February 2012 - 11:26 PM, said:

first there shouldn’t be the comma and I’m not sure if it’s a good idea to have the image path absolute to the local file system and not relative (or absolute) to the host.

Thank you, I removed the comma, but still doesn't work :/

This post has been edited by bita: 07 February 2012 - 01:30 PM

Was This Post Helpful? 0
  • +
  • -

#4 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3392
  • View blog
  • Posts: 9,586
  • Joined: 08-June 10

Re: loading image from computer to browser

Posted 07 February 2012 - 01:34 PM

I donít think the comma would have caused the problem. try using a relative path to the image.

btw. are you calling the page through localhost?
Was This Post Helpful? 1
  • +
  • -

#5 bita  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 190
  • Joined: 21-April 09

Re: loading image from computer to browser

Posted 07 February 2012 - 01:49 PM

A relative path has been tried. No result yet!

And I'm completely a beginner in HTML, what do you mean by:

Quote

are you calling the page through localhost?


I wrote codes in Notepad, Save them as .htm type, and then open the file with my browser(Firefox) on my computer.

Again, thanks for helping :)
Was This Post Helpful? 0
  • +
  • -

#6 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3392
  • View blog
  • Posts: 9,586
  • Joined: 08-June 10

Re: loading image from computer to browser

Posted 07 February 2012 - 01:51 PM

weeelll, I guess you donít use a web server then. try the following URL for the image: sophia.JPEG (assuming you saved the .htm file in C:\Users\Sophia\Desktop\html\)
Was This Post Helpful? 1
  • +
  • -

#7 bita  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 190
  • Joined: 21-April 09

Re: loading image from computer to browser

Posted 07 February 2012 - 02:16 PM

No, I don't use a web server, and it doesn't work again. I dunno, maybe I did something wrong in my coding that I don't know about. :(
Was This Post Helpful? 0
  • +
  • -

#8 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3392
  • View blog
  • Posts: 9,586
  • Joined: 08-June 10

Re: loading image from computer to browser

Posted 07 February 2012 - 02:17 PM

what does the browserís address bar show?
Was This Post Helpful? 0
  • +
  • -

#9 bita  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 190
  • Joined: 21-April 09

Re: loading image from computer to browser

Posted 07 February 2012 - 02:29 PM

file:///C:/Users/Sophia/Desktop/html/img.htm
Was This Post Helpful? 0
  • +
  • -

#10 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3392
  • View blog
  • Posts: 9,586
  • Joined: 08-June 10

Re: loading image from computer to browser

Posted 07 February 2012 - 02:36 PM

then <img src="sophia.JPEG" alt="sth" width="600" height="700"> should work. though using http://localhost/~Sophia/img.htm instead of file:///C:/Users/Sophia/Desktop/html/img.htm would be more appropriate Ö (though that needs preparation before you can do that)
Was This Post Helpful? 1
  • +
  • -

#11 Sho Ke  Icon User is online

  • D.I.C Head
  • member icon

Reputation: 107
  • View blog
  • Posts: 246
  • Joined: 13-October 11

Re: loading image from computer to browser

Posted 07 February 2012 - 03:14 PM

It also may be worth checking to see if the image is saved as .jpg or .jpeg.
Was This Post Helpful? 1
  • +
  • -

#12 bita  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 190
  • Joined: 21-April 09

Re: loading image from computer to browser

Posted 08 February 2012 - 02:13 AM

View PostSho Ke, on 08 February 2012 - 01:44 AM, said:

It also may be worth checking to see if the image is saved as .jpg or .jpeg.

It has been checked sho ke :) but the problem is not that.
Was This Post Helpful? 0
  • +
  • -

#13 Sho Ke  Icon User is online

  • D.I.C Head
  • member icon

Reputation: 107
  • View blog
  • Posts: 246
  • Joined: 13-October 11

Re: loading image from computer to browser

Posted 08 February 2012 - 06:19 AM

Could it be that you don't have a <head> tag? All HTML documents are required to have a beginning and ending <head> tag before the body starts, but still within the <html> tag.
It should look something like this:
<html>
<head>
	<title> </title>
</head>
<body>

</body>
</html>


Was This Post Helpful? 1
  • +
  • -

#14 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3392
  • View blog
  • Posts: 9,586
  • Joined: 08-June 10

Re: loading image from computer to browser

Posted 08 February 2012 - 06:28 AM

View PostSho Ke, on 08 February 2012 - 02:19 PM, said:

Could it be that you don't have a <head> tag? All HTML documents are required to have a beginning and ending <head> tag before the body starts, but still within the <html> tag.

actually, the <head> element (opening and closing tag) is optional, though the appointed HTML structure should be used to make maintainable HTML documents.
Was This Post Helpful? 0
  • +
  • -

#15 revolutionx  Icon User is offline

  • D.I.C Head

Reputation: 60
  • View blog
  • Posts: 229
  • Joined: 23-July 09

Re: loading image from computer to browser

Posted 08 February 2012 - 06:30 AM

Ok, so you have the image (jpg) and htm file inside the html folder on your desktop, correct?

So the image code in the html page should look like this:

<img src="sophia.JPEG" alt="sth" width="600" height="700" />



As we want to use a relative path, and not an absolute one. If you update your htm file and run it again with that img code does it work?
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2