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 / getfilefrompath.cfm < prev    next >
Encoding:
Text File  |  2001-06-13  |  1.7 KB  |  59 lines

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