0

Earlier i was displayed the image by referring current directory. My current directory is '/opt/lampp/htdocs/cms/'. My images was placed in the folder called 'Images' inside the cms folder. So, i have displayed the images by referring "./images/filename.png". Now i have moved the images outside of cms folder. Now i kept the images folder inside htdocs directory. Now i refer the path by '/opt/lampp/htdocs/Images/filename.png'. but now the images was not displayed.

<?php
$ImagePath = "/opt/lampp/htdocs/Images/test1_01.png";
?>
<IMG width="180" height="120" align="right" alt="No Image" src="<?php echo $ImagePath; ?>" />

Edited by arunsolo1984: n/a

2
Contributors
3
Replies
5
Views
5 Years
Discussion Span
Last Post by almostbob
0

/ in this case refers to the root folder of your lampp installation,
usually /whatever/htdocs, not the root of your current physical drive,
php cannot see any part of the drive outside the http root by drive structure, else / on my .com would be the server root, not my site root
If lampp is installed default the 'dos' equiv path the server expects when you key
/opt/lamp/htdocs/Images/test_01.png
is
/opt/lamp/htdocs/opt/lamp/htdocs/Images/test_01.png

from /opt/lampp/htdocs/cms/
to /opt/lampp/htdocs/Images/test1_01.png
is ../images/test_01.png

hope this makes sense

Edited by almostbob: n/a

0

I have already tried it and works fine. But in my case, Images folder may be present in anywhere in the file system. For eg., if it was present in /home/arun/PreEncryptor/outputdir, how can i refer the image?

0

examine the file:// protocol perhaps, or cascade .. to the root
from /opt/lampp/htdocs/cms/
to root of the drive is
../../../..
so the new url is ../../../../home/arun/PreEncryptor/outputdir/image.png
not so hard in php where anything that repeats or is reused, can be
eg

<?php $path ="../../../../home/arun/PreEncryptor/outputdir/";
//code to get filenames from somewhere
echo $path.$filename;
echo $path.$filename2;
echo $path.$filename3; 
// and some code to do something interesting with them
?>

Edited by almostbob: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.