Jump to content

IMG SRC wrong path from XAMPP localhost


grissom

Recommended Posts

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 !

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.