Forums

how to preserve file upload filename and path from local client if upload action fails

saveg 07 Jan, 2020
Im having 16 file upload fields in a multipage form and Im doing a size and ext check after submit button and checking is server side.
the problem Im having is that the if filefield1 fails a faill msg is shown (as Im doing action redirect when failure) but all filefield2 / filefield3 / filefield4 ..... loses the file selected. is there a way a just keep the value for the file selected on those file fields.
healyhatman 07 Jan, 2020
Don't use a redirect use an event loader. You can also use a switcher area for each field with {var.empty:fileuploadactionname} with the "true" event showing the field (because if it's empty, no file was uploaded and you need to show the field. If it's false, a file WAS uploaded and you don't need to upload again.)
saveg 07 Jan, 2020
yes well spot on.
Actually I was using event loader.
Can I use the action name inside the fieldswitcher even before calling??
Im still not getting the idea can you pls explain it more?
saveg 07 Jan, 2020
Here is what Im doing, shall I insert file field inside 0 and 1 or how?
action name is upload6 upload7
saveg 07 Jan, 2020
could you pls confirm that the path is preserved using switcher area????
saveg 07 Jan, 2020
What I really need is to preserve the file paths and file name when the fail is triggered so that all file selected for upload are kept intact unless user click on browse and select another file.
any idea?
GreyHead 08 Jan, 2020
Hi saveg,

Personally I would keep it simple and upload the files from each page when that page is submitted and I would save the data to a 'provisional' database record at the same time. When the next page is submitted upload the files from that page and update the database record. On final submission validate the data and change the status of the record from 'provisional' to 'confirmed'. To keep things tidy you can also run a cron job every so often to look for 'provisional' records more than say 24 hours old and delete the corresponding files and the record.

You don't normally have access to the path of the files on the users computer - though I guess it might be possible to grab it using JavaScript.

Bob
saveg 08 Jan, 2020
thanks for clarification but would the below statement apply and fix the file paths and selected file?

Don't use a redirect use an event loader. You can also use a switcher
area for each field with {var.empty:fileuploadactionname} with the
"true" event showing the field (because if it's empty, no file was
uploaded and you need to show the field. If it's false, a file WAS
uploaded and you don't need to upload again.)

saveg 08 Jan, 2020
I meant would you the switcher area fix this problem?? and if yes Im can someone explain the logic clearly?
saveg 08 Jan, 2020
ive done {var.empty:upload6} and its working fine and not showing in the next event loader.
it did the trick and well done for the idea, but if the user again makes wrong file type upload for the next submit. the file field acually shows again. how can I prevent it from re showing once it successful ie never show once the file is accepted no matter the number of submit ?
dont forget we have 16 files to upload and user is dumb enough to make wrong types and sizes. we want to fully control it?
saveg 09 Jan, 2020
anyone there???
can I use double switcher area to overcome this problem??? is it nested switcher area or how can I overcome this problem
healyhatman 09 Jan, 2020
Costs you nothing to try. Could also store in session with data builder 2 that the file was uploaded and use {session.empty:namegoeshere}
saveg 09 Jan, 2020
thanks for clarification. actually I did do {session.empty:actionnamehere} and seems to be working. just wondering will this eat up memory on the server as I will endup doing 19 sessions created and saved
healyhatman 09 Jan, 2020
Unless you have billions of concurrent users I doubt it's going to matter.
This topic is locked and no more replies can be posted.