Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CFFILE error processing

Status
Not open for further replies.

calista

Programmer
Jan 24, 2001
545
US
I am working on an error processing template for a form that uploads files to the server. Currently, on my action page, I have NAMECONFLICT set to "Error", and I send the user to an error processing page. I want to give them three choices: cancel, overwrite, or view the pre-existing file, and if they select "View pre-existing file", then, once they see the contents of the file, give them the option of cancel or overwrite. Any suggestions? I am considering setting NAMECONFLICT as a variable, and pass back a URL variable depending on the user's choice. If the the user chooses "Overwrite", I would like to send an "Are you sure?" message before actually doing it. Plus, how would I preserve the name of the pre-existing file? It looks like the form variable contains the contents of the file, not a link to it, and I don't think I can pass the contents of the file as a URL variable. Thanks in advance! Calista :-X
Jedi Knight,
Champion of the Force
 
Hey Calista,

This one is a little tricky but here's what I would reccomend.

1. Allow the upload with nameConflict set to "makeUnique".
2. Check cffile.fileWasRenamed to see if there was a conflict.
3. If so, redirect to an error page passing the variables "cffile.serverFile" and "cffile.clientFile".
4. On the error page, give the three options and pass through the two cffile variables to the next action page.
5. If the user selected "cancel", user cffile to delete the file named originally in "cffile.serverFile". If the user selects preview, pass both variables again to a page that shows the file named in the original #cffile.clientFile#. If the users selects overwrite, use cffile to delete the file named #cffile.clientFile# (passed through at this point in a new variable) and then rename the original file named in #cffile.serverFile# to #cffile.clientFile#.
6. The preview page option will just pass the variables and the new action again to step 5.

Basically, if there was a name conflict, you know that the file name on the server matched the name of the file sent by the users (cffile.clientFile = cffile.serverfile) so we use these in manipulating the files. Since you know the directory of the initial upload, you just need to pass the names of the files and not the actual files. You will need a cleanup script to run occasionally in case someone doesn't complete the transaction and leaves an un-processed file.

Let me know if you have any trouble with it,
GJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top