0

We have am html code saved as .php because it includes a form that requires php. However, the image we've inserted isn't displaying on the browser while everything else is. Here's our coding:

<IMG SRC = "D:\xampp\htdocs\1.jpg" width = "650" height = "400">

We also tried this :

<?php
$media = fopen("1.jpg", 'r');
echo $media;
fclose($media);
?>

However, it returns "resource id #3" and I don't know how/what else to do to display the image.

Please help.

5
  • Why are you accessing image with physical path? Commented Nov 5, 2016 at 11:30
  • Set your image full access path EXAMPLE PATH: /var/www/html/project/uploads/1.jpg. Commented Nov 5, 2016 at 11:32
  • In your first example, why are you using a file system path? In your second example, that's not how you write an image to the output. Commented Nov 5, 2016 at 11:34
  • i think the root will be the localhost which is htdocs , check the config file Commented Nov 5, 2016 at 11:37
  • Also, due to the fact that browsers are fickle instruments, make sure you use the proper markup: <img src="folder/image.jpg" width="650" height="400"> - that means no spaces in the HTML code. And really, no all-caps tags either... Commented Nov 5, 2016 at 11:43

2 Answers 2

3

if your script is inside a folder in htdocs folder USE

<IMG src="../1.jpg" width = "650" height = "400">

else if your script is inside htdocs folder USE

<IMG src="1.jpg" width = "650" height = "400">

Sign up to request clarification or add additional context in comments.

Comments

0

Let image the directory-

D -> xampp 
-> htdocs
         -> 1.jpg
         -> file.php

then you can access your image as:

<img src="1.jpg" alt=""/>

if image is inside any folder like upload then

<img src="upload/1.jpg" alt=""/>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.