简体   繁体   中英

Correct file path img src, image not loading PHP HTML

I'm trying to echo out an image in a PHP function using 'img src', but I can't get it to work. The function itself works fine, everything else that I return or echo is working.

The image is located 1 folder 'back / up', then into the folder 'images' and the name of the image I'd like to acces in the 'images' folder is 'nike1.jpg'.

The following code isn't working:

echo '<img src="../images/nike1.jpg">';

No idea what I'm doing wrong here. Thanks in advance!

You need to check your path. I am little confused that you have "back" and "up" as two different folders or its one folder. It should be like "/your_parent_directory/back/up/images/nike1.jpg" or you can also write as "../back/up/images/nike1.jpg" if back and up are two folders. Can you tell the full path of the image.

Not a real answer, but I decided to upload the image(s) on imgur and just use the image URL. Thanks for all the support.

Its because your image files don't have proper read permission, make sure those image files are readable.If you are an Linux user type the bellow command which will provide all access to the file.

First go to the image file directory in terminal and type the following.

sudo chmod 777 *

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM