Problem to load image in specific hosting

Asked

Viewed 227 times

2

Someone uses the company’s hosting service 000webhost to do tests ? I am facing a problem with images that are not loading, the 'folder' is there and the 'image' is there with the correct names but still does not load

I really have no idea what it might be.

File code index php.

<div class="logo">
    <figure>
        <img src="logo/logo.png" alt="Logo da empresa Hard">
        <figcaption>
            Logo da empresa Hard
        </figcaption>
    </figure>
</div>

This is the server’s html response

inserir a descrição da imagem aqui

aba network

inserir a descrição da imagem aqui

  • Checks in the Console if you are returning an error.

  • no error on console

  • And on the tab Network ? This which the status returning ?

  • updated the post

  • 1

    Ever tried to put the full path? With the website address? Are you using .htaccess ?

  • yes I tried using $_SERVER['HTTP_HOST']."/logo/logo.png" and the same mistake happens

  • does it have something to do with the . php extension of the index? why I made a site with extension . html and loaded the images correctly.

  • Jah tested in other browsers?

  • yes I tested on Mozilla and Chrome

Show 4 more comments

2 answers

1

Surely it must be problem in the link path, or the image does not exist on the server (try to access it directly by link of the image in the browser).


A solution and tip for your project:

I believe you have a file on config/settings which is added on all pages, to make connections to the database or define variables used in the project. Set the full link in this file and call anywhere in the code. Example:

define('_BASE_URL_', 'http://www.exemplo.com.br/');
define('_BASE_URL_SSL_', 'https://www.exemplo.com.br/');
define('_JS_DIR_', _BASE_URL_.'js/');
define('_CSS_DIR_', _BASE_URL_.'css/');
define('_IMG_DIR_', _BASE_URL_.'images/');

So you can have a better control of your project by simply printing the variable with the name of the file you want to load on the page.

<img src="<?php echo _IMG_DIR_."logo.png"; ?>">
  • yes I already made this way also however I did not succeed but thanks for the tip

  • 1

    I continued the project and took it off the air, when it is more complete I will put in Github then I send you.

  • 1

    and the face beauty? then as the knowledgeable ones up there did not manage to answer they decided to close the page but here the solution just put the <img> within a <section> and solved ready project follows link of site http://hardmaquinas.com.br/

-1

Have you tried using the base in your index?

Don’t forget the first Slash "/"

<base href="/Diretorio completo da sua img">

Browser other questions tagged

You are not signed in. Login or sign up in order to post.