MACROMEDIA COLDFUSION 5 - INSTALING AND CONFIGURING SERVER Manual de Instruções Página 126

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 154
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 125
116 Lesson 4 Validating Data to Enforce Business Rules
Reviewing the code
The following table describes the code used to verify whether a file exists:
Exercise: use FileExists function to verify the existence of photo file name
In this exercise, you will use the Cold Fusion
FileExists function to ensure that the
photo file name entered in the Trip Edit page exists in the location specified.
To verify that the photo file name exists:
1 Open the tripeditaction.cfm in the my_app directory in your editor.
2 In the tripeditaction.cfm page, do the following:
a Add logic to check that the user entered a valid photo file name by copying the
code from the photofilecheck.txt file in the solutions directory pasting it
immediately following the first <cfset isOk = "Yes"> statement.
b Verify that code you copied in step a is pointing to the correct photolocation
path. The path is specified in the <cfset PhotoLocation = "C:..."> tag.
For example, depending on your web server configuration, the photolocation
path might be:
For MS Windows systems:
<cfset PhotoLocation
"C:\cfusionmx\wwwroot\CFDOCS\getting_started\Photos\">
or
<cfset PhotoLocation =
"C:\Inetpub\wwwroot\CFDOCS\getting_started\Photos\">
For Linux or Solaris systems:
<cfset PhotoLocation =
"/opt/coldfusionmx/wwwroot/cfdocs/getting_started/photos/">
or
<cfset PhotoLocation =
"/<webserverdocroot>/cfdocs/getting_started/photos/">
Code Explanation
<cfif IsDefined("form.testFileName")>
The cfif tag checks to see if the form variable
testFileName has been entered.
<cfset fileLocation = fileLocation &
form.testFileName>
The ColdFusion & operator in the cfset tag
combines the original value for fileLocation
from the first source line
("c:\inetpub\wwwroot\images\") with the value
of the testFileName form variable.
<cfif FileExists(fileLocation)>
FileExists checks to see if the file indicated by
the fileLocation variable exists at the specified
disk location.
Vista de página 125
1 2 ... 121 122 123 124 125 126 127 128 129 130 131 ... 153 154

Comentários a estes Manuais

Sem comentários