Archived from the Transloadit support forum. Originally posted on February 25, 2014; details may be outdated, see our docs for current behavior. Original thread
Hi
I need to keep the file input tag inside a single form that is on my page. I cannot use more than one.
I’m using the jquery upload so that the image is uploaded when the file is selected. All working great.
But, when I press my other submit button, the system seem to try an upload an empty form …
Is it possible to have the transloadit not do ‘anything’ if a js variable is set to false somewhere? Or something similar / better?
did what you said. During the first upload I simply hit “cancel” in the jQuery plugin’s modal and then uploaded a different file. It all seemed to work fine, which it should.
it would be easier to split this into two forms yes - one dedicated for uploading, one dedicated for your other fields. In the onSuccess callback of the jQuery plugin you can take the first parameter to it (the assembly object) and copy that to a new hidden form field in your second form and then set a flag that the second form can be submitted (or make its submit button visible then or whatever).
var uploader = $(‘#upload-form’).data(‘transloadit.uploader’);
var isBound = !!uploader;
Yes, just set triggerUploadOnFileSection to true in the options to the plugin.
autoSubmit specifies whether to submit the original form automatically once the upload and processing have completed. So when you hit “Submit” the upload is then done of course. But once it is completed, it will not submit the original form if you set autoSubmit to false.
Please let me know if this helps.
Kind regards,
Tim
Co-Founder Transloadit @tim_kos
Edit: Tender, our support system, ate my list numbers. -.-
Can you make it so that the form is bound (at the start) and unbound (if a form validation error is found), then successfully re-bound after the message has been delivered? (without any js errors)
However, my question 3 was:
* Can I use a button to initiate an upload, rather than it just ‘happening’ when selecting a file?
o This meant, when you select a file – I want nothing to happen.
o I’d then have a button next to it called ‘upload file’, which when clicked would initiate the upload – rather than doing it automatically or if my main form is submitted.
The answer supplied was:
* Yes, just set triggerUploadOnFileSection to true in the options to the plugin.
Can you make it so that the form is bound (at the start) and unbound (if a form validation error is found), then successfully re-bound after the message has been delivered? (without any js errors)
I don’t see any trouble why this shouldn’t be possible. Did you run into any issues?
I’d then have a button next to it called ‘upload file’, which when clicked would initiate the upload – rather than doing it automatically or if my main form is submitted.
Oh okay, that makes more sense now. So you basically want an optional file upload right? Like I said, this is best done in a separate form, where you would just attach the assembly JSON to your main form in the onSuccess(assembly) callback. If you do not use a separate, then the file will still be uploaded (to your server) in case someone selected a file for the file input field.
If you have more questions let’s move the discussion to Skype as that will be easier. My Skype username is transloadit_tim.