NetTalk Central

Author Topic: Cancel on a form uploads a file  (Read 3301 times)

ccordes

  • Sr. Member
  • ****
  • Posts: 384
    • View Profile
    • Email
Cancel on a form uploads a file
« on: February 14, 2013, 04:12:29 PM »
Hi
I want users to be able to upload a file or two. So I use a form so they can enter the description of the file, click the upload button, select their file, come back to the form, then click Save. The file and the description gets saved file gets saved everyone goes home happy.
BUT if the user changes their mind, and clicks Cancel, the description record is rightly ignored, and the file STILL GETS SAVED and there in lies the rub.
I don't see a way around this. I must be missing something.
Is there a way to cancel the upload?

TIA,
chris
Real programmers use copy con newapp.exe

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Cancel on a form uploads a file
« Reply #1 on: February 14, 2013, 09:58:05 PM »
Hi Chris,

You must think of this in an "asynchronous" way.
The user is uploading the file (with the progress bar) - then clicks on save or cancel.
The two actions are "unrelated" (in a sense.)

there are a couple ways to beef up the cancel to delete any uploaded files - but you'll need to be a bit creative;

a) use the file name to link it back to the reocrd, then if the record is cancelled REMOVE the file. For example, say the record id is 1234, then you could prefix the file names with 1234- ; if record 1234 is cancelled then delete all files starting with 1234-. (This approach presumes the record has an ID before inserting, in and auto-number kind of way)

b) move the file when the record is OK. For example, the file got uploaded into "uploads". But when the user clicks ok, it moves the file into say the "uploaded" folder. Then from time to time you can clean out files in the "uploads" folder, based on the name (say if it includes a session id) or the date (if it's a few days old.)

cheers
Bruce

ccordes

  • Sr. Member
  • ****
  • Posts: 384
    • View Profile
    • Email
Re: Cancel on a form uploads a file
« Reply #2 on: February 15, 2013, 08:18:50 AM »
Thanks. I've given it a rest and will look at it again asynchronously.
Real programmers use copy con newapp.exe