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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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) #>#evaluat e('form.tx tFileSaveP ath')#\</c fif>
</td>
<td>
</td>
<td> #form.txtFileSavePath#
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<cfif #FILE.fileWasOverwritten#>
<td> Old File Size :
</td>
<td> #FILE.oldFileSize#
</td>
<cfelse>
<td>
</td>
<td>
</td>
</cfif>
</tr>
<tr>
<td> Time Created :
</td>
<td> #FILE.timeCreated#
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td colspan="4">
<hr align="center" width="80%" size="5">
</td>
</tr>
</table>
</cfmail>
and some checks
<cfif isDefined("SESSION.Auth.Us erID") and isDefined("SESSION.Auth.Ac cessLevel" )> <!--- Validate User Level --->
<cfif #SESSION.Auth.AccessLevel# GE 100>
<cfif Find('\..',#form.txtFileSa vePath#) or Find('\.',#form.txtFileSav ePath#) or not findNoCase(rootPath,form.t xtFileSave Path,1)>
<cfif FILE.fileWasSaved>
<cfoutput>
<meta http-equiv="Refresh" content="10;URL=siteManage r.cfm?pth= #form.txtF ileSavePat h#">
</cfoutput>
File upload was successful
<cfelse>
Error during file upload<br>
<cfoutput>
<meta http-equiv="Refresh" content="10;URL=siteManage r.cfm?pth= #form.save Path#">
</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
<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)
</td>
<td>
</td>
<td> #form.txtFileSavePath#
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<cfif #FILE.fileWasOverwritten#>
<td> Old File Size :
</td>
<td> #FILE.oldFileSize#
</td>
<cfelse>
<td>
</td>
<td>
</td>
</cfif>
</tr>
<tr>
<td> Time Created :
</td>
<td> #FILE.timeCreated#
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td colspan="4">
<hr align="center" width="80%" size="5">
</td>
</tr>
</table>
</cfmail>
and some checks
<cfif isDefined("SESSION.Auth.Us
<cfif #SESSION.Auth.AccessLevel#
<cfif Find('\..',#form.txtFileSa
<cfif FILE.fileWasSaved>
<cfoutput>
<meta http-equiv="Refresh" content="10;URL=siteManage
</cfoutput>
File upload was successful
<cfelse>
Error during file upload<br>
<cfoutput>
<meta http-equiv="Refresh" content="10;URL=siteManage
</cfoutput>
<br /><br />
<cfoutput>
<a href="siteManager.cfm?pth=
</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
<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#