Setup a variable in your application.cfm or global_variables file that
defines paths to images and other things.

E.g

<cfset application.Imageuploadpath = ExpandPath('.\images\uploads')>
<!--- this calculates the location of the current running file on the
server and appends \images\uploads to it, so if your index.cfm was
running from e:\mysite\wwwroot you would end up with say
e:\mysite\wwwroot\images\uploads --->

<cfset application.ImageRoot = "/images/"> <!--- specify the browser
path to that folder --->

You must remember when using expandpath, that it always works relative
from the location of the current file. So if you declare a variable in
your application.cfm, you should make sure it only ever gets created
once when the application.cfm first runs in the root. Because the
relative location will be calculated from the file that caused
application.cfm to run, not the application.cfm itself.
Every CFM file causes the application.cfm to be run first.
So if you have a file in wwwroot/subfolder/myfile.cfm that uses
application.Imageuploadpath, it will have been calculated from
/wwwroot/subfolder and not /wwwroot because that's where applciation.cfm
was last run from.

So ideally you need a check around all your global variables so they
only get created once.

E.g

<cfif not isdefined('application.variables')>

<cfset application.variables = "set">
Create other application variables.
</cfif>

Remember to LOCK when creating application variables. Although this
isn't meant to be required in cFMX.

For variables that doesn't matter if they get re-created mor ethan once,
yopu can use REQUEST scope.

HTH

Russ Michaels
Macromedia/Allaire Certified ColdFusion Developer
 
CFDeveloper
The free resource and community for ColdFusion developer.
http://www.cfdeveloper.co.uk

Join the CFDeveloper discussion lists.
To subscribe send an e-mail to [EMAIL PROTECTED]





> -----Original Message-----
> From: Jolly Green Giant [mailto:[EMAIL PROTECTED] 
> Sent: 24 October 2003 20:43
> To: [EMAIL PROTECTED]
> Subject: [ cf-dev ] Trying not to use absolute paths
> 
> 
> Hi All,
> 
> I have an image I want to put in various places on my 
> website.  Well it's 
> actually a spliced up image held together by a table.  I want 
> to avoid 
> using absolute paths.  What do you guys do for this situation?
> 
> I could make a tag that counts how many directories there are 
> back to the 
> main one and then prepends each image source declaration with the 
> appropriate number of "../".
> 
> Anyone got any brighter ideas?
> 
> Thanks for any help!
> 
> JGG 
> 
> 
> -- 
> ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
> 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: 
> [EMAIL PROTECTED] For human help, e-mail: 
> [EMAIL PROTECTED]
> 


-- 
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]

Reply via email to