Link to home
Create AccountLog in
Avatar of chris36583
chris36583

asked on

CFFILE Help

I have a page that uploads a file to my server via coldfusion using cffile...... After the file is uploaded how do i show a status page instead of just reloading the original upload page?
ASKER CERTIFIED SOLUTION
Avatar of SidFishes
SidFishes
Flag of Canada image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
How about
<cftry>
<cffile ... code />
<b>Upload Successfull</b>
<cfdump var="#cffile#">
<cfcatch>
#cfcatch.message#
</cfcatch>
</cftry>

if you don't want to dump the whole cffile structure then by looking at it will give you the keys available to access the values
like: FILEWASSAVED : #CFFile.FILEWASSAVED#
here is a cfmail block usedin a fikleupload group that advises teh user of teh file status after upload, just change it from cfmail to cfoutput, make it look nice and tioy have a screen presentad after the user uplloads a file

<cfmail from="canregeis@ups.com" to="#SESSION.Auth.Email#" type="HTML" subject="Confirmation of file posting">
            
            <table cellspacing="1" cellpadding="1" align="center">
                     <tr>
                           <td colspan="4" align="center">      File Posting Confirmation
                           </td>
                     </tr>
                     <tr>
                                       <td colspan="4" align="center">      Local File Details
                                       </td>
                                 </tr>
                                                         <tr>
                                       <td>      File Name :
                                       </td>
                                       <td>      #FILE.clientFileName#
                                       </td>
                                       <td>      File Type :
                                       </td>
                                       <td>      #FILE.clientFileExt#
                                       </td>
                                 </tr>
                                 <tr>
                                       <td>      File Size :
                                       </td>
                                       <td>      #FILE.fileSize#
                                       </td>
                                       <td>      Uploaded File Name :
                                       </td>
                                       <td>      #FILE.clientFile#
                                       </td>
                                 </tr>
                                 <tr>
                                       <td colspan="4" align="center">      Server File Details
                                       </td>
                                 </tr>
                                 <tr>
                                       <td>      File Name :
                                       </td>
                                       <td>      #FILE.serverFileName#
                                       </td>
                                       <td>      File Type :
                                       </td>
                                       <td>      #FILE.serverFileExt#
                                       </td>
                                 </tr>
                                 <tr>
                                       <td>      File Size :
                                       </td>
                                       <td>       #FILE.fileSize#
                                       </td>
                                       <td>      Saved File Name :
                                       </td>
                                       <td>      #FILE.serverFile#
                                       </td>
                                 </tr>
                                 <tr>
                                       <td>      File Existed :
                                       </td>
                                       <td>      #FILE.fileExisted#
                                       </td>
                                       <td>      File Overwritten :
                                       </td>
                                       <td>      #FILE.fileWasOverwritten#
                                       </td>
                                 </tr>
                              <tr>
                                       <td>      Save Path :
                                       </td>
                                       <td>      <cfif #len(form.txtFileSavePath)#>#evaluate('form.txtFileSavePath')#\</cfif>
                                       </td>
                                       <td>      
                                       </td>
                                       <td>      #form.txtFileSavePath#
                                       </td>
                                 </tr>
                                 <tr>
                                       <td>      &nbsp;
                                       </td>
                                       <td>      &nbsp;
                                       </td>                                             
                                       <cfif #FILE.fileWasOverwritten#>
                                             <td>      Old File Size :
                                             </td>
                                             <td>      #FILE.oldFileSize#
                                             </td>
                                       <cfelse>
                                             <td>      &nbsp;
                                             </td>
                                             <td>      &nbsp;
                                             </td>
                                       </cfif>
                                 </tr>
                                 <tr>
                                       <td>      Time Created :
                                       </td>
                                       <td>      #FILE.timeCreated#
                                       </td>
                                       <td>      &nbsp;
                                       </td>
                                       <td>      &nbsp;
                                       </td>
                                 </tr>
                                 <tr>
                                       <td colspan="4">
<hr align="center" width="80%" size="5">
                                       </td>
                                 </tr>

               </table>
      </cfmail>      

and some checks


<cfif isDefined("SESSION.Auth.UserID") and isDefined("SESSION.Auth.AccessLevel")>                  <!--- Validate User Level --->                        
<cfif #SESSION.Auth.AccessLevel# GE 100>
<cfif Find('\..',#form.txtFileSavePath#) or Find('\.',#form.txtFileSavePath#) or not findNoCase(rootPath,form.txtFileSavePath,1)>

<cfif FILE.fileWasSaved>
      <cfoutput>
<meta http-equiv="Refresh" content="10;URL=siteManager.cfm?pth=#form.txtFileSavePath#">
</cfoutput>
File upload was successful
      
<cfelse>
Error during file upload<br>

<cfoutput>

<meta http-equiv="Refresh" content="10;URL=siteManager.cfm?pth=#form.savePath#">
</cfoutput>
<br /><br />
<cfoutput>
<a href="siteManager.cfm?pth=#url.pth#">click here to continue</a> or wait to be redirected automatically
</cfoutput>
</cfif>
                                
</cfif>

</body>
</html>
<cfelse>
<cflocation url="levelError.cfm">

</cfif>
<cfelse>
<cflocation url="error.cfm">

</cfif>

the first 3 cfifs are system dependent to the aplpication this wwas copied from