|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
How to use ExpandPath
Hello All,Paige Chandler 06/11/03 01:18 A I would do it like this:Josh Trefethen 06/11/03 02:53 A I find a good way to debug this is to display it then eyeball it:Matthew Walker 06/11/03 01:39 A Expnadpath takes a relative path, so use "images/...".Pascal Peters 06/11/03 02:41 A Yes, the fact that it's relative to the *base* template caused me untold frustration before I found that out. What is the strategy behind it working that way, instead of being relative from the current template? It does not make for easy-to-read code.Mike Mertsock 06/11/03 11:05 A If you want relative to the current template you can useMike Townend 06/11/03 11:14 A BTW you should add the contextroot to URLS too .webguy 06/11/03 11:19 A This helped much! Thanks!Angel Stewart 06/11/03 11:28 A >If you want relative to the current template you can useMike Mertsock 06/11/03 03:27 P What you can do is set them in the Application.cfm and assign them to aMike Townend 06/11/03 03:39 P Hello All, Is the following the correct usage of ExpandPath? <CFIF FileExists(ExpandPath("Images\#Trim(Session.Client_ID)##Trim(Session.Insured_ID)#1.jpg"))> <INPUT Type="button" Value="View Certificate - page 1" Name="Search1" onClick="window.location='http:\CVS3WP14.CFM'"> <INPUT Type="button" Value="View Certificate - page 2" Name="Search1" onClick="window.location='http:\CVS3WP15.CFM'"> </CFIF> The .jpg image does exist. I don't get a error but it doesn't display the buttons either. Help will be appreciated. TIA. Regards, Paige I would do it like this: <cfif fileExists( expandPath('./Images') & trim(session.client_ID) & trim(session.insured_ID) & '1.jpg')> <!--- yada yada yada ---> </cfif> HTH, -- Josh Trefethen .:::::[ Exciteworks, Inc ]::[ http://exciteworks.com ]:::::. .::[ cf hosting on linux ]::[ consulting ]::[ expertise ]::. ----- Excess quoted text cut - see Original Post for more ----- I find a good way to debug this is to display it then eyeball it: !<cfoutput>#ExpandPath("Images\#Trim(Session.Client_ID)##Trim(Session.Insure d_ID)#1.jpg")#</cfoutput>! ----- Excess quoted text cut - see Original Post for more ----- Expnadpath takes a relative path, so use "images/...". Also expandpath calculates a full path from the relative path starting from the base template (the one you requested in the URL). Otherwise this use of Expandpath is correct. -----Oorspronkelijk bericht----- Van: Paige Chandler [mailto:ceaser@erols.com] Verzonden: wo 11/06/2003 7:16 Aan: CF-Talk CC: Onderwerp: How to use ExpandPath Hello All, Is the following the correct usage of ExpandPath? <CFIF FileExists(ExpandPath("Images\#Trim(Session.Client_ID)##Trim(Session.Insured_ID)#1.jpg"))> <INPUT Type="button" Value="View Certificate - page 1" Name="Search1" onClick="window.location='http:\CVS3WP14.CFM'"> <INPUT Type="button" Value="View Certificate - page 2" Name="Search1" onClick="window.location='http:\CVS3WP15.CFM'"> </CFIF> The .jpg image does exist. I don't get a error but it doesn't display the buttons either. Help will be appreciated. TIA. Regards, Paige Yes, the fact that it's relative to the *base* template caused me untold frustration before I found that out. What is the strategy behind it working that way, instead of being relative from the current template? It does not make for easy-to-read code. Mike Mertsock Alfred University Web Team If you want relative to the current template you can use GetCurrentTemplatePath() I usually use that with GetDirectoryFromPath() wrapped around it in my Application.cfm page for things like image upload paths ExpandPath() is for converting the URL script name into an absolute path HTH Yes, the fact that it's relative to the *base* template caused me untold frustration before I found that out. What is the strategy behind it working that way, instead of being relative from the current template? It does not make for easy-to-read code. Mike Mertsock Alfred University Web Team BTW you should add the contextroot to URLS too . Check out Seans blog for details, www.corfield.org If you want relative to the current template you can use GetCurrentTemplatePath() I usually use that with GetDirectoryFromPath() wrapped around it in my Application.cfm page for things like image upload paths ExpandPath() is for converting the URL script name into an absolute path HTH Yes, the fact that it's relative to the *base* template caused me untold frustration before I found that out. What is the strategy behind it working that way, instead of being relative from the current template? It does not make for easy-to-read code. Mike Mertsock Alfred University Web Team This helped much! Thanks! :) I didn't even know I needed help but I just made a little file upload routine I was writing a lot more efficient than hardcoding an Application variable called imagepath. -Gel If you want relative to the current template you can use GetCurrentTemplatePath() I usually use that with GetDirectoryFromPath() wrapped around it in my Application.cfm page for things like image upload paths ExpandPath() is for converting the URL script name into an absolute path HTH ----- Excess quoted text cut - see Original Post for more ----- Oh i see. So ExpandPath's argument is a like a relative URL. But those other two functions are so freakin long to type! MM What you can do is set them in the Application.cfm and assign them to a variable, then at any point you have a reference to the root... Ie Application.cfm <CFSET sRoot = GetDirectoryFromPath(GetCurrentTemplatePath())> Upload.cfm <CFFILE ACTION="Upload" FILEFIELD="foo" DIRECTORY="#sRoot#"> Etc ----- Excess quoted text cut - see Original Post for more ----- Oh i see. So ExpandPath's argument is a like a relative URL. But those other two functions are so freakin long to type! MM
|
September 06, 2010
|
Latest Fusion Authority Articles
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||