Newbie: cannot get images to display if navigate to my webpage

Newbie: cannot get images to display if navigate to my webpage

Post by AC » Thu, 09 Jul 2009 07:03:57

Hi

I have an issue when trying to display images.

I have created a webpage containing images on my harddrive, and that
single webpage works perfectly well if I view it by itself. The html
file is in a folder (say folderX) and that same folder contains the
images I want to display on that webpage. If I open that webpage in
firefox or safari it displays the pics perfectly. Lets call that
webpage myPage.html.

My problem is that if I have a different webpage which contains a link
to the myPage.html webpage, when I click on the link it opens up to
the webpage but the pics are broken. And if I click on the pictures
the error in firefox is something like: cannot find file c:\folderX
\myPage.html\mypic.jpg

So for some reason the name of my webpage is turning up in the file
path to the picture.
It should say c:\folderX\mypic.jpg.

And as mentioned above, if I were to open myPage.html directly in
firefox/safari it works perfectly fine, this issue ONLY happens if I
navigate, via links on a different webpage I have created, to
myPage.html


Is this a known problem with a simple fix?

Thanks
AndyC

 
 
 

Newbie: cannot get images to display if navigate to my webpage

Post by David E. R » Thu, 09 Jul 2009 07:09:33


You have to upload the image files to the same server that contains your
HTML files.

Some browsers do not allow access to someone's own hard drive. This is
a security feature. After all, do you want me snooping into your PC?

--

David E. Ross
< http://www.yqcomputer.com/ ;.

Don't ask "Why is there road rage?" Instead, ask
"Why NOT Road Rage?" or "Why Is There No Such
Thing as Fast Enough?"
< http://www.yqcomputer.com/ ;

 
 
 

Newbie: cannot get images to display if navigate to my webpage

Post by Molly Mock » Thu, 09 Jul 2009 07:45:03

At 15:03:57 on Tue, 7 Jul 2009, AC < XXXX@XXXXX.COM > wrote in
< XXXX@XXXXX.COM >:


That is because the web page is looking for the picture on your own
local drive. And because, once you have uploaded the web page, it is
part of the Whole Wicked Web, it has no idea of where a c:\ drive might
be.

In your own local copy of the web page, edit your HTML so that any
reference to images which starts with c:\folderX\ becomes simply
\folderX\.

Re-upload your HTML file.

Make sure you have uploaded your images.

Oh, and make sure that where you refer to your images, the name is
correct with full case-sensitivity: File.JPG is very different from
file.jpg on the web, although your own local computer will think it's
the same. But that's not your problem; it's the absolute paths to your
own hard disk which are the problem.

(Don't mention it, that'll be 3/6d please.)
--
Molly Mockford
They that can give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety - Benjamin Franklin
(My Reply-To address *is* valid, though may not remain so for ever.)
 
 
 

Newbie: cannot get images to display if navigate to my webpage

Post by AC » Thu, 09 Jul 2009 07:56:46

Hi

Thanks for the help so far everyone, I appreciate it.

Molly - I am not sure that is the issue, or am i missing something
really basic here...

My html had already done exactly what you were suggesting, ie
MyPage.html code simply contains <img src="myPic.jpg" /> I dont have
c:\ anywhere in my html code.

plus

I have not uploaded my html files to any server anywhere. They only
exist on my harddrive. I have not put these on the www anywhere yet,
i want to get it all working on my harddrive first.

If I view myPage.html it works
If I put a link to myPage.html on a different *local* webpage
(remember, i have not put this on the www yet) and click the link it
opens myPage.html but the pics are now broken. The path to the pics
contains the string "myPage.html\myPic.jpg"

So as far as I can make out it is adding the string "myPage.html" as
part of the path to the pic. I do not understand why. It does not
add this as part of the path to the pic if I open up myPage.html on
its own, it only does this if I open the page via a link.

Thanks
Andy C


On Jul 8, 10:45m, Molly Mockford < XXXX@XXXXX.COM >
 
 
 

Newbie: cannot get images to display if navigate to my webpage

Post by Beauregard » Thu, 09 Jul 2009 08:38:18


Or more better: /folderX/

--
-bts
-Friends don't let friends drive Windows
 
 
 

Newbie: cannot get images to display if navigate to my webpage

Post by John Hoski » Thu, 09 Jul 2009 09:16:11


Andy, please don't top-post.


Well, points to it, more precisely.


In general, reporting problems is more efficient when you can report the
exact message text of any errors. Probably not relevant here, but something
to consider in typical troubleshooting situations.


Posting a bunch of code is frowned on here (as top-posting is) but if
myMasterPage.html contains little more than the link to myPage.html, I
think the best thing is to paste the entire contents of myMasterPage.html
into a reply here. I suspect you've got a BASE element set, but I'd like to
see the code. (My BASE theory could be, uh, way off base.)

About top-posting and t *** sigs and other unnecessaries out of replies,
read < http://www.yqcomputer.com/ ;, especially the section
< http://www.yqcomputer.com/ #quote>. Thanks.

HTH
--
John
 
 
 

Newbie: cannot get images to display if navigate to my webpage

Post by Jonathan N » Thu, 09 Jul 2009 09:40:21


Hmm, I highly doubt it! Firefox will not find nor display *any* path
with a Windows-specific "\" folder delimiters, on IE will do that.
Firefox and other web browsers will find a local path as

file:///c:/folderX/mypic.jpg

Anyway what you want to do is use relative paths. If you have a file
structure

FolderA

FolderA/FolderB

FolderA/FolderC


SCENARIO 1
If example.html is in FolderA and references image is the *same* folder,
FolderA then

<img src="example.jpg" alt="works">
or
<img src="./example.jpg" alt="works">


SCENARIO 2

But if the image is in a child folder FolderB or Folder C then

<img src="FolderB/example.jpg" alt="works">
or
<img src="./FolderB/example.jpg" alt="works">

and

<img src="FolderC/example.jpg" alt="works">
or
<img src="./FolderC/example.jpg" alt="works">

will work respectively


SCENARIO 3
Where page is in either FolderB or FolderC but the image is in FolderA
then use "../" for the parent folder

<img src="../example.jpg" alt="works">


SCENARIO 4
Where the page is in FolderB an the image is in an adjacent sibling
folder FolderC then

<img src="../FolderC/example.jpg" alt="works">


Lastly, if your page is on a different "Windows drive or partition" then
you need a web server. Local paths don't really translate as URLs...



--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.yqcomputer.com/
 
 
 

Newbie: cannot get images to display if navigate to my webpage

Post by John Dunlo » Thu, 09 Jul 2009 18:34:23

Beauregard T. Shag *** :



Well, if we're discussing URLs, and not some proprietary way of referring
to local resources, slashes are not only better than backslashes but they
are also allowed while backslashes are not. The src attribute takes a URL,
so HTML forbids backslashes in the src attribute value.

--
John