The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> href works locally but not on website
Columbo
post Jan 6 2024, 09:15 PM
Post #1





Group: Members
Posts: 2
Joined: 6-January 24
Member No.: 29,111



I put href in topic title but meant to put <img src=.
I am putting together a website using html and css and I am using Brackets for the editor. I have a navbar (css) with 4 links on it and they are all working properly on the website. One of those links in the navbar points to another page (page 2) on the site. That other page contains a link to an image that is in a folder called dino_images. The link code that I am using is:
CODE

<div class="picture">
     <img src="dino_images/anomalocaris.jpg" alt="anomalocaris">      
  </div>


When I run the code locally in Brackets, it runs fine and displays the images properly. When I upload the files to the website the images do not display and it shows a broken link. The structure on the website is identical to the folder on my hard disk that Brackets is using to run the code locally. The dino_images folder is on the website and the image does exist in the dino_images folder with the correct spelling. I've been playing around with this thing for a whole day and I can't figure out why it running properly locally but is indicating a broken link on the website. The path is correct.

Any suggestions appreciated.

This post has been edited by Columbo: Jan 6 2024, 09:25 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Jan 7 2024, 01:39 AM
Post #2


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,733
Joined: 9-August 06
Member No.: 6



What error message do you get?

If a 404 I don't understand since you have already checked all possible causes. If the image is corrupt and not loaded for that reason you should get another message. Can you view the image if you go directly to it with a browser? I.e type the full URLto it in the nav bar.

If you can, please post the URL the page with the link to the image.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Jan 7 2024, 07:18 AM
Post #3


.
********

Group: WDG Moderators
Posts: 9,661
Joined: 10-August 06
Member No.: 7



QUOTE(Columbo @ Jan 7 2024, 03:15 AM) *

That other page contains a link to an image that is in a folder called dino_images. The link code that I am using is:
CODE

<div class="picture">
     <img src="dino_images/anomalocaris.jpg" alt="anomalocaris">      
  </div>


Technically that's an IMG element, not a link.

QUOTE
The structure on the website is identical to the folder on my hard disk that Brackets is using to run the code locally. The dino_images folder is on the website

Is it in the same folder as the HTML file?

QUOTE
and the image does exist in the dino_images folder with the correct spelling.

Note that URLs are case-sensitive (but not on Windows' file system).

See also https://htmlhelp.com/faq/html/images.html#broken-image
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Jan 7 2024, 08:07 AM
Post #4


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,733
Joined: 9-August 06
Member No.: 6



The OP said the file structure and case are the same. And, provided the whole bunch was uploaded at the same time as the content of a folder, it's hard to see how anything could go wrong with that. If the files were uploaded one by one, well, it's easier to so how mistakes could happen.

But if we can see the actual page we hopefully can figure it out.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Jan 7 2024, 02:03 PM
Post #5


.
********

Group: WDG Moderators
Posts: 9,661
Joined: 10-August 06
Member No.: 7



QUOTE(pandy @ Jan 7 2024, 02:07 PM) *

The OP said the file structure and case are the same.

I saw nothing about case. unsure.gif

QUOTE
But if we can see the actual page we hopefully can figure it out.

True, that's the easiest method.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Jan 7 2024, 03:10 PM
Post #6


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,733
Joined: 9-August 06
Member No.: 6



I assumed "correct spelling" included that. But you are right. Sorry, I only thought about the same case locally and on the server.

Columbo, assuming the you are on Windows there could be a case mismatch between the file name and the URL and it would still work locally since Windows isn't case sensitive, I.E the image could be named Anomalocaris.jpg, anomalocaris.JPG or have some other letter or letters in upper case. It would still work on Windows but not on most servers. Have you checked that?


User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Columbo
post Jan 7 2024, 09:29 PM
Post #7





Group: Members
Posts: 2
Joined: 6-January 24
Member No.: 29,111



Thank you for all the responses. It appears that the image file might have been corrupt. I finally did what I should have done long ago and uploaded the image to the website again and it now displays ok. Not sure why it was showing as a broken link though.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Jan 8 2024, 04:03 AM
Post #8


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,733
Joined: 9-August 06
Member No.: 6



You mean you got an error message? Browsers don't load corrupt images (or if it is the server that doesn't serve them...). IIRC the message you get depends on the browser. I seem to recall some browser gives you some information about the error and others say something more generic.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 27th April 2024 - 03:30 PM