PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Saving File Upload State When Saving User Form Progress

  1. I've got a form that is split into 3 pages. Users are required to create an account before they can fill out the form. The form is lengthy, so my client would like for users to be able to save their progress and come back at a later time to fill out the form. I have two forms of saving the data, one utilizing a button that they can push to automatically save the data (it is stored as a JSON string via user meta) and then I attach to the GF event when moving from one page to the next (both using AJAX).

    While you can check to pre-populate fields via query strings or hooks, etc, it is not really realistic to do with such a giant form. So rather I am filtering the shortcode output itself and using the Simple DOM Html Parser library to traverse through the output and prepopulate field values. Here is the code I am using for this: https://gist.github.com/3415027

    This works perfectly (albeit a little slower than I would like, but it is reliable and allows users to access saved form data from anywhere as long as they are logged in) minus the state of file uploads. I know this area is tricky because uploads aren't completely processed until the form is submitted. Lines 40-50 of the gist work perfectly at adding the correct value back to the input file field, but I wanted to see if there was a way to somehow store the upload state of the file and restore that when the user returns. Likely this involves using some temporary directory to hold the upload data, but I'll be honest, I tried hunting through the GF code to see how it handles it and it was just too messy for me to find anything useful. :-)

    I figured I would ask and see if you had any ideas where to start. Once I get this down, I plan on making a tutorial for how to do it. Apart from testing for some other different types of form elements and logic, saving the state of form progress is now pretty feasible. I plan on creating a solid tutorial once I'm done with the project.

    Posted 12 years ago on Tuesday August 21, 2012 | Permalink
  2. With file uploads, I think you are going to run into browser security issues:

    http://stackoverflow.com/questions/4684013/is-it-possible-to-re-populate-a-file-select-form-field-with-what-the-user-previo

    The file will either be uploaded or not. If it's uploaded, I think you are done, you have the information and the file. If it's not uploaded, I think you would have a hard time repopulating the form with the information needed to continue the upload.

    Did you come up with anything else to help you with this?

    Posted 12 years ago on Saturday August 25, 2012 | Permalink