473,395 Members | 1,905 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

problem in displaying image

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
5 1705
Markus
6,050 Expert 4TB
Is the image located in your htdocs?
Dec 30 '07 #2
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
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
6,050 Expert 4TB
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
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

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

Similar topics

6
by: Kingdom | last post by:
I'm using this script to dynamicaly populate 2 dropdowns and dispaly the results. Choose a component type from the first drop down, lets say 'car' and the second box will list all the car...
11
by: Ian Davies | last post by:
Hello Im having problems displaying my images as thumbnails in a table. My code for producing the new width and height from the original image is as follows...
3
by: Irfan Akram | last post by:
Hi Guys, I am having problems displaying an image from the database, that alreday has been uoploaded successfully. The image loads in correctly, but by default it is displayed on the whole...
3
by: c676228 | last post by:
Hi everyone, I have a piece of code in sales.aspx.vb like this: Protected WithEvents Message As System.Web.UI.WebControls.Label Try ... ChartImage.ImageUrl = "ChartGenerator.aspx?" + DataStr +...
4
by: comp.lang.php | last post by:
'll try to explain this as clearly as possible, sorry if it's unclear. You have in your directory /foo 42 images You have in your database metadata for 30 out of those 42 images You have to...
14
by: Brad | last post by:
I have a .net 2.0 web application project that creates a pdf file, saves the pdf to disk (crystal reports does this part), and then my code reads the pdf file and writes it to the httpresponse ...
4
by: =?Utf-8?B?Qkw=?= | last post by:
I am in a problem to access user control(.ascx) on a .aspx page the following is my scenario I have following directory structure - Autoboom - workshop -- WSFirst -showroom
4
by: shahidrasul | last post by:
i display a pic on picture box and then i want to display another pic after some seconds but problem is that first image is not displaying only display 2nd image 1... display first picture from...
3
by: mvijayrkumar | last post by:
Hi to all.... Guys pls help me..... I have an image issue in RLDC while hosting my project on server.The image displays or works fine with the local system.But when hosted on server,both the...
6
by: vikidigi | last post by:
PLz Help i have some Images in DataBase in Blob field but images are displayed with a Cross (X) not the actual image MainPage.php//code # <?php # $con =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.