House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

How to use ExpandPath

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Paige Chandler
06/11/2003 01:18 AM

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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Josh Trefethen
06/11/2003 02:53 AM

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 -----

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Matthew Walker
06/11/2003 01:39 AM

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 -----

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Pascal Peters
06/11/2003 02:41 AM

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   

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Mike Mertsock
06/11/2003 11:05 AM

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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Mike Townend
06/11/2003 11:14 AM

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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
webguy
06/11/2003 11:19 AM

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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Angel Stewart
06/11/2003 11:28 AM

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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Mike Mertsock
06/11/2003 03:27 PM

----- 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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Mike Townend
06/11/2003 03:39 PM

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


<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

September 06, 2010

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
       1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30