Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File paths in include files

Status
Not open for further replies.

emozley

Technical User
Jan 14, 2003
769
GB
Hi,

I have a file saved in my root folder called topsection.asp that contains the line:

<img src="graphics/logo.gif">

Then in my index.asp file I have the line:

<!--#include file="topsection.asp"-->

This works fine if topsection.asp and index.asp are in the same folder. If they're not (eg index.asp is in a subfolder called 'reports') and I change index.asp to:

<!--#include file="../topsection.asp"-->

then the path to the graphic is wrong. I tried to get round this by specifying the absolute path to the file in topsection.asp - eg:

<img src="
This fine but then when I upload the files to the website the file path to logo.gif is obviously wrong. Is there a way round this so I can get the best of both worlds - eg be able to call my include file from any folder or subfolder and the file paths all work ALSO for it to work on both my home server and my hosted website without changing any code?

Thanks very much

Ed
 
I always use a variable for my website virtual directory that I declare in an #include file. Then I only have to change it in one place if I move my site.

For example:

myinclude.asp
Code:
Dim strSitePath

strSitePath = "[URL unfurl="true"]http://localhost/mywebsite/"[/URL]

mypage.asp
Code:
<img src="<%=strSitePath%>images/logo.gif" alt="Logo" />

Tony
---------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top