-6

HTML:

<img src="file:///C:/Users/magnu/Downloads/IMG_0342.JPG" alt="logo">

When I run the code in a browser locally on my PC, the image displays. But not when I view the site online. What am I doing wrong?

CSS:

img{
    width:210px;
    length:210px;
    -webkit-transform:rotate(270deg);
    -moz-transform: rotate(270deg);
    -ms-transform: rotate(270deg);
    -o-transform: rotate(270deg);
    transform: rotate(270deg);
    position:absolute;
    left:600px;
    top:300px;
  }
Zappoh
  • 27
  • 1
  • 6
  • 4
    Update image's `src` attribute to server path. – Mohammad Usman Aug 31 '17 at 13:19
  • You have to place the image file inside a path within your online site directory, then write the path to that place. Local files outside the scope of the site root path can't be accessed by it. – Tiramonium Aug 31 '17 at 13:20
  • 1
    You should read a bit about file systems / paths, because it should be obvious to everyone working with web technologies that `file:///C:/Users/magnu/Downloads/IMG_0342.JPG` specifies a file on your local machine and therefore can not work on your online web server. – domsson Aug 31 '17 at 13:24
  • You might want to also check out [this related question](https://stackoverflow.com/questions/2005079/absolute-vs-relative-urls) and maybe [that one](https://stackoverflow.com/questions/24028561/relative-path-in-html) too. – domsson Aug 31 '17 at 13:25

3 Answers3

7

img{
    width:210px;
    height:210px;
    -webkit-transform:rotate(270deg);
    -moz-transform: rotate(270deg);
    -ms-transform: rotate(270deg);
    -o-transform: rotate(270deg);
    transform: rotate(270deg);
    position:absolute;
    left:100px;
    top:100px;
  }
<img src="http://images.all-free-download.com/images/graphiclarge/beautiful_nature_landscape_05_hd_picture_166223.jpg" alt="logo">

Put your image on server. There are many options using which you can put your image online like imgur, imgbb

instead of giving length give height to your image.

Hope this helps.

Bhavin Shah
  • 2,462
  • 4
  • 22
  • 35
0

you have to set its location comppared with the location the html file for example if html file is located in c:/html/ and img is located in c:/ you should to set img src as follow src="../img.jpg" "../" to retun back by one folder

Ayoub Benayache
  • 1,046
  • 12
  • 28
-1

IN the src you have to write the path without "file///":

<img src="C:/Users/magnu/Downloads/IMG_0342.JPG" alt="logo">
  • Do you really think this will work on his online webserver? – domsson Aug 31 '17 at 13:48
  • If the server is Windows based, yes it work. If the server is Linux based, he has to modify the path to one similar to "/home/mysiye/media/randomimage.jpg". All this only if the site's files are in the same server. If he doesn't host the site in the same server of the static files, he have to write a path like this: "https ://mysite.com/myfolderimages/myimages/". – Simone Degano Aug 31 '17 at 13:50