grissom Posted May 2, 2011 Share Posted May 2, 2011 Hi all I am running XAMPP on my laptop and working with files not in the localhost directory. For functions like fopen, there is no problem, I specify a path starting from the localhost directory to wherever I want to work and that's fine. For some reason though, it is NOT working with IMG SRC. I get my PHP to generate the following line of code : <IMG SRC = "http://localhost/../../../wherever/android.jpg"> (which in this case points to C:\wherever\android.jpg) However the browser misses the middle bit of the URL out and interprets it just as localhost/wherever/android.jpg - which clearly doesn't exist ! Likewise, if I try typing the address straight into the address bar, the '../../../' bit of it immediately vanishes. I've tried formatting the URL in a variety of ways, none of them seem to work, where am I going wrong ? Many thanks ! Quote Link to comment https://forums.phpfreaks.com/topic/235346-img-src-wrong-path-from-xampp-localhost/ Share on other sites More sharing options...
Pikachu2000 Posted May 2, 2011 Share Posted May 2, 2011 fopen() and other php functions use a path relative to the filesystem root. HTML tags use a path relative to the web document root. It isn't likely that there are sufficient permissions for the image to be grabbed from a directory above the web root. For that reason, you should organize the directory structure as it would be on a live production server. Quote Link to comment https://forums.phpfreaks.com/topic/235346-img-src-wrong-path-from-xampp-localhost/#findComment-1209457 Share on other sites More sharing options...
grissom Posted May 2, 2011 Author Share Posted May 2, 2011 Thanks Pikachu. I'll do exactly that. Thanks once again. Quote Link to comment https://forums.phpfreaks.com/topic/235346-img-src-wrong-path-from-xampp-localhost/#findComment-1209458 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.