Archived from the Transloadit support forum. Originally posted on September 1, 2012; details may be outdated, see our docs for current behavior. Original thread
I have a basic form with a single file upload. When the user submits the form, I want the upload to happen and redirect normally. Here is the code I have: https://gist.github.com/3584962
Right now the upload happens and the processing happens when the form is submitted even though I have wait set to false. After the form upload/process is done, I want the form to behave normally and continue with the posts#create action but redirect never happens and it tries to look for a ‘create’ view (create.html.erb)
Here is the process I would like to implement:
Form is submitted with file attached Upload happens The redirect happens normally in the posts#create action Transloadit does the processing and notifies the server when done.
I tried setting the notify_url as a parameter to transloadit_jquerify but that does not help.
Another question now How to implement upload progress for each image like https://www.picplum.com homepage image upload. They also use you guys.
It looks like they added a good amount of custom code using our jQuery API to create individual uploads / assemblies for each file input, including custom display code. We’re working on adding more features like this into our jQuery plugin in the future, but for now this requires customization code on your end.
Did not really help much. Any parameter I am missing to only submit/process with transloadit if a file is selected.
Well, you simply attach your own form submit handler (before attaching the jQuery plugin). In this submit handler you cancel the event (e.preventDefault(), etc.) in case it doesn’t pass your requirements (like file input fields being filled).
Last question, promise: How to implement ‘http/import’ with the rails sdk?
You just add an import step at the beginning of your assembly, and for every step that is supposed to use the imported file(s), you set "use": "step_name".
Awesome got it working. We are using the “fields” paramater on the jquery plugin to send a url along with the transloadit parameters and then access that via “${fields.url}” in the template. Is that the right way to get http/import working ?
Also I guess the rails sdk will not without a “regular” file upload field i.e. if we only want to implement a upload from url.
I’m one of the maintainers of the rails-sdk, hope I can help.
We are using the “fields” paramater on the jquery plugin to send a url along with the transloadit parameters and then access that via “${fields.url}” in the template. Is that the right way to get http/import working ?
Yep this looks correct and works if you want to set the URL dynamically via a form or similar.
Also I guess the rails sdk will not without a “regular” file upload field i.e. if we only want to implement a upload from url.
The rails-sdk doesn’t care much about your form, it’s just a thin wrapper around the jquery-sdk with some convenience methods. But to be sure I just tested it without a file upload field and it works as expected.