By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,955 Members | 1,756 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,955 IT Pros & Developers. It's quick & easy.

problem in displaying image

P: 52
Hey all,

I have a strange type of problem.

I have a simple code of html (say in test.html)
[HTML]<img src="/home/Shreedhan/edited_shreedhan2.jpg" />[/HTML]

If I put this code in a separate file and open it directly, it works fine.

But if I open same file in apache ( i mean like "localhost/test.html")
then, it doesn't show the image at all

Isn't that strange?
Is there any solution to this
Dec 30 '07 #1
Share this Question
Share on Google+
5 Replies


Markus
Expert 5K+
P: 6,050
Is the image located in your htdocs?
Dec 30 '07 #2

P: 52
Yeah, the image I am trying to display using PHP is located in /var/www/html/uploads/shreedhan

I have tried displaying other images which are in /home/shreedhan directory as well. But its not displaying other images also.
I have given the complete path in the 'src' attribute
Further I have given read, write and execute permissions to the /var/www/html/uploads/shreedhan directory

Thanks
Dec 30 '07 #3

P: 52
Hey,

I got a temporary solutiong for my problem.
Instead of giving full path of the image like
[HTML]<img src="/var/www/html/uploads/shreedhan/sth.jpg" />[/HTML]

I included followin line[HTML]<img src="http://localhost/uploads/shreedhan/sth.jpg" />[/HTML]

It displays the image properly.
But what if I have to include images from other directories than /var/www/html

Thanks
Dec 31 '07 #4

Markus
Expert 5K+
P: 6,050
Hey,

I got a temporary solutiong for my problem.
Instead of giving full path of the image like
[HTML]<img src="/var/www/html/uploads/shreedhan/sth.jpg" />[/HTML]

I included followin line[HTML]<img src="http://localhost/uploads/shreedhan/sth.jpg" />[/HTML]

It displays the image properly.
But what if I have to include images from other directories than /var/www/html

Thanks
So, i'm guessing this works too:
<img src="uploads/shreedhan/sth.jpg" />

The reason the pics arent working is because you're going away from your htdocs. To use pics from elsewhere on your pc use the direct path to that.

e.g
[php]
C:/xampp/htdocs/images/DockEdit.jpg
C:/some_dir/another_dir/_images/image.jpg
[/php]
Dec 31 '07 #5

P: 52
So, i'm guessing this works too:
<img src="uploads/shreedhan/sth.jpg" />
Yeah this also works.

The reason the pics arent working is because you're going away from your htdocs. To use pics from elsewhere on your pc use the direct path to that.

e.g
[php]
C:/xampp/htdocs/images/DockEdit.jpg
C:/some_dir/another_dir/_images/image.jpg
[/php]

Actually, I am providing full path. I use linux so the path for the image starts from root '/'.
/var/www/html is the default directory to host webpage (as it is htdocs in case of windows)
Even though I provide full path '/var/www/html/uploads/shreedhan/edited_shreedhan2.jpg' , it's not showing the image.
But if I provide 'uploads/shreedhan/edited_shreedhan2.jpg', it's showing the image, because it's in the same directory where pictures.php (the file with including above images) is stored.

I haven't been able to include images outside of /var/www/html
Dec 31 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.