Jump to content

using full URL for img


coderb

Recommended Posts

I'll explain how I'm trying to use it.

 

I'm building an html page dynamically, previewing the content in the current page and then writing it as page.html

page.html is written to a different directly, so now I have the problem that images dynamically added have the wrong path.

To fix this I would need to use an absolute/full URL for the image location, but don't want to hardcode it.

just thought there must be a way to get the full path of a current location?

 

thanks

Hi all,

A newbie question.

How do I define the full URL in my html image? So instead of

<img src="images/top_invoice.gif" width="560" height="33"/>

 

I'd like, something like <img src=.relative url./images/top_invoice.gif" width="560" height="33"/>

 

thanks

 

If your domain is test.com

If you want relative url, relative path or root path.

'<img src=' . $_SERVER['DOCUMENT_ROOT'] . '/images/top_invoice.gif' etc.....

would yeild www.test.com/images/top_invoice.gif

 

Would allow you to have just one images folder instead of an images folder in every folder which you will need if using:

"<img src=\"" . $_SERVER['PHP_SELF'] . "/images/top_invoice.gif\">";

would yeild www.test.com/current_folder/images/top_invoice.gif

 

 

 

Hi all,

A newbie question.

How do I define the full URL in my html image? So instead of

<img src="images/top_invoice.gif" width="560" height="33"/>

 

I'd like, something like <img src=.relative url./images/top_invoice.gif" width="560" height="33"/>

 

thanks

 

If your domain is test.com

If you want relative url, relative path or root path.

'<img src=' . $_SERVER['DOCUMENT_ROOT'] . '/images/top_invoice.gif' etc.....

would yeild www.test.com/images/top_invoice.gif

 

Would allow you to have just one images folder instead of an images folder in every folder which you will need if using:

"<img src=\"" . $_SERVER['PHP_SELF'] . "/images/top_invoice.gif\">";

would yeild www.test.com/current_folder/images/top_invoice.gif

 

 

 

 

To fix this I would need to use an absolute/full URL for the image location' date=' [b']but don't want to hardcode it.[/b]

just thought there must be a way to get the full path of a current location?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.