home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 February / CHIPCD_02_2002.iso / Internet / Macromedia ColdFusion Server 5 / coldfusion-50-win-us.exe / data1.cab / Examples / CFDOCS / snippets / getdirectoryfrompath.cfm < prev    next >
Encoding:
Text File  |  2001-06-13  |  1.7 KB  |  57 lines

  1. <!--- This example shows the use of GetDirectoryFromPath --->
  2. <HTML>
  3. <HEAD>
  4. <TITLE>
  5. GetDirectoryFromPath Example
  6. </TITLE>
  7. </HEAD>
  8.  
  9. <BASEFONT FACE="Arial, Helvetica" SIZE=2>
  10. <BODY  bgcolor="#FFFFD5">
  11. <H3>GetDirectoryFromPath Example</H3>
  12.  
  13. <p>This is a read-only example. Because file access is a sensitive area,
  14. consider the security of your directory hierarchy prior to allowing
  15. access to it.</p>
  16. <!--- 
  17. <CFSET thisPath=ExpandPath("*.*")>
  18. <CFSET thisDirectory=GetDirectoryFromPath(thisPath)>
  19. <CFOUTPUT>
  20. The current directory is: #GetDirectoryFromPath(thisPath)#
  21. <CFIF IsDefined("form.yourFile")>
  22. <CFIF form.yourFile is not "">
  23. <CFSET yourFile = form.yourFile>
  24.     <CFIF FileExists(ExpandPath(yourfile))>
  25.     <P>Your file exists in this directory.  You entered
  26.     the correct file name, #GetFileFromPath("#thisPath#/#yourfile#")#
  27.     <CFELSE>
  28.     <P>Your file was not found in this directory:
  29.     <BR>Here is a list of the other files in this directory:
  30.     <!--- use CFDIRECTORY to give the contents of the
  31.     snippets directory, order by name and size --->
  32.     <CFDIRECTORY DIRECTORY="#thisDirectory#"
  33.     NAME="myDirectory"
  34.     SORT="name ASC, size DESC">
  35.     <!--- Output the contents of the CFDIRECTORY as a CFTABLE --->    
  36.     <CFTABLE QUERY="myDirectory">
  37.     <CFCOL HEADER="NAME:"
  38.             TEXT="#Name#">
  39.     <CFCOL HEADER="SIZE:"
  40.             TEXT="#Size#">
  41.     </CFTABLE>
  42.     </CFIF>
  43. </CFIF>
  44. <CFELSE>
  45. <H3>Please enter a file name</H3>
  46. </CFIF>
  47. </CFOUTPUT>
  48.  
  49. <FORM action="getdirectoryfrompath.cfm" METHOD="post">
  50. <H3>Enter the name of a file in this directory <I><FONT SIZE="-1">(try expandpath.cfm)</FONT></I></H3>
  51. <INPUT TYPE="Text" NAME="yourFile">
  52. <INPUT TYPE="Submit" NAME="">
  53. </FORM> --->
  54.  
  55. </BODY>
  56. </HTML>       
  57.