I have a setup with a traditional form that's checked with jQuery Tools validator and submitted via POST. I like that this class does not require extra classnames or other superfluous metadata to validate, standard HTML5 attributes are enough.
I now would like to extend this functionality with the Plupload upload solution. I know that all modern upload solutions work via Ajax these days, so I was thinking about a setup in which the user fills out the form, puts files in the upload queue and then submits the form. The form submit would imply:
- Validation through jQuery Tools Validator...
- If validated, uploading all files in the upload queue... (to a temporary folder)
- If upload went well, actual submit of the form via POST and moving files from temporary folder to permanent location.
I had a similar setup in place with Uploadify, where the filenames where appended into a hidden input field after succesful upload. On submit of the form, I thus had all filenames via $_POST. However, there were conflicts between jQuery Tools Validator and Uploadify. That's why I'm now looking into Plupload.
My questions?
- What do you think of this setup? Is this a good strategy?
- How would I go about implementing this on a technical level?
Thanks.
I've found the answer. Plupload has this very nice functionality built in. It is designed to fit into an existing form. It uses AJAX to upload the files, but it returns the results of the upload before posting the form synchronously. This way, on posting a form enriched with Plupload, you also have the result of the upload in your POST variables.
It isn't really clear in the documentation, but after you submit a sample form from the examples, it states:
"Uploading is a bit different than you might be used to, files are uploaded to the temp folder, then when the form is submitted you get all the info you need to move around the files to the correct location. It's designed this way to make it easier to just apply it to an existing form. The low level core API has support for both methods."
Very nice upload solution. Some minor issues here and there, but I'm sure PEBKAC