Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
134 views
in Technique[技术] by (71.8m points)

image - why differences there in .html file on local host and .html file uploaded on web?

index.html

 <html>
    <head>
        <title>image</title>
    </head>
    <body>
        
        <p> 
            <img src="kRIsten stewart.jpg" width="200"  height="200"  alt="Kristen stewart" title="Kristen stewart" />
            <img src="pics/Emilia clarke.jpg" height="200" width="200" alt="emilia clarke" title="emilia clarke" />
            <img src="jordan-peterson.jpg" height="200" width="200" alt="jorden-peterson" title="jorden-peterson" />
            <img src="pics/Kate winslet.jpg" height="200" width="200" alt="kate winslet" title="kate winslet" />
            <img src="/4. Codes/HTML/hosted2/Mel robbins.jpg" height="200" width="200" alt="Mel robbins" title="Mel robbins"/>
            <img src="raining gif.gif" height="200" width="200" alt="raining gif" title="raining gif" />

            
        </p>

    </body>
</html>

Location : F:/4. codes/html/hosted2/

This hosted2 folder is hosted on surge.sh . It contains index.html file, jorden-peterson.jpg, kristen stewart.jpg, Mel robbins.jpg, raining.gif. It also contains a folder named pics, which contains Emilia clarke.jpg, and kate winslet.jpg.

When I open this index.html using file scheme file:/// F:/..., all 6 pics display in the web-browser.

But when I open this file through URL http://unsuitable-rate_bonapart.surge.sh/ where it is hosted, I am unable to see kristen stewart.jpg and Mel robbins.jpg. Why is that ?

1.kristen stewart.jpg.

I make 2 letters uppercase while giving path in index.html file KRIsten stewart.jpg. But in location the file is kristen stewart.jpg

5.Mel robbins.jpg

/4. Codes/HTML/hosted2/Mel robbins.jpg I gave absolute path.

So what I feel that on browser while uploading I uploaded hosted2 folder so it doesn't know upper folders to that(hosted2) so It can't show Mel robbins.jpg and kristen stewart.jpg. I feel it's due to surge.sh might have policy that the file name should be case sensitive.

So I feel this. I don't know exactly. Please explain why this is happening.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

First of all don't use spaces in your img src (replace them by "-" or "_").

If your kristen stewart's file name is kristen-stewart.jpg then call it by kristen-stewart.jpg not kRIsten-stewart.jpg.

Then /4. Codes/HTML/hosted2/Mel robbins.jpg is not an absolute path. An absolute path will be (for example) https://yourdomainname.com/yourimage.jpg. So maybe consider relative path or a valide absolute path.

Note: Add "./" at the beginning of your src to use the same folder and "../" to move to the upper folder.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...