echo '<img src="../../images/delete.png" id="aaa" />aaa '; (working fine)
//define( 'ROOT_DIR', dirname(__FILE__) ); is in a file at root folder.
//i able to use this ROOT_DIR to include class files without any problem
//BUT, when I use it with photo ima开发者_Go百科ge, it just not working!
echo '<img src="'.ROOT_DIR.'/images/delete.png" id="bbb" />bbb';
Guys, any idea what's wrong?
Probably because you are mixing directory path and URI. The directory where your script is located is different then it's URI in your website. You should define a ROOT_URI
constant that would held the top URI of your application and use it.
echo '<img src="../../images/delete.png" id="aaa" />aaa '; (working fine)
//define( 'ROOT_URI', 'some/uri' ); is in a file at root URI.
echo '<img src="'.ROOT_URI.'/images/delete.png" id="bbb" />bbb';
You need to work from the web server root, not the file system root.
If your main page is /var/www/html/index.html
and your image is /var/www/html/images/delete.png
, then your image href should be /images/delete.png
.
instead of using ROOT_DIR try http://".$_SERVER["SERVER_NAME"].'/images...
精彩评论