Flag of Ukraine

Multipart Form Multipart Form

We originally built this approach to avoid the need to have JavaScript enabled in the browser. Times have changed and one can now assume that JavaScript is turned on in the browser, so we recommend using Uppy as the browser integration of choice.

That being said, to showcase basic concepts, do a quick prototype, or in case you really do want to offer a fallback for browsers where JavaScript is disabled or crashed, you can integrate Transloadit using nothing more but a multipart <form>.

Even though we recommend Uppy, to showcase basic concepts, do a quick prototype, or in case you really do want to offer a fallback for browsers where JavaScript is disabled or crashed, you can integrate Transloadit using nothing more but a multipart <form>.

Install

There is nothing to install :ok_hand:

Usage

Set the form's action attribute to "https://api2.transloadit.com/assemblies". Files are then uploaded directly to our API, along with any Instructions inside a hidden params field.

To avoid any parsing issues in the browser, we should let a computer JSON encode the instructions and then escape HTML entities such as: < and " to &lt; and &quot;. The result is a little hard for a human to parse, so maybe don't even try :smile:

You can set a redirect_url inside the Instructions to tell our API to redirect the browser to a success page of your choosing when all is done. We'll append: ?assembly_id=xyz&assembly_ssl_url=https://api2.transloadit.com/assemblies/xyz to that URL.

When serving out the success page, your back-end could parse these query parameters so you can do further handling like downloading the Assembly Status JSON and the encoding results it refers to.

The success page is served to the browser as soon as the upload completes, so the Assembly may actually still be executing (encoding a large video for instance). You could either poll the assembly_ssl_url with your back-end, or you could set up Assembly Notifications and provide a notify_url with your Instructions. In that case we will POST the Assembly Status JSON to it so you can handle the results with your back-end that way.

Example

<!--
We'll be inlining the following Assembly Instructions into a hidden `params` field,
escaping HTML entities such as `<`, a task best left to machines : )

{ 
  "auth": { "key": "YOUR_TRANSLOADIT_KEY" }, 
  "redirect_url": "https://example.com/success", 
  "template_id": "YOUR_TEMPLATE_ID"
}
-->

<form method="POST" enctype="multipart/form-data" action="https://api2.transloadit.com/assemblies">
  <input type="hidden" name="params" value='{ &quot;auth&quot;: { &quot;key&quot;: &quot;YOUR_TRANSLOADIT_KEY&quot; }, &quot;redirect_url&quot;: &quot;https://example.com/success&quot;, &quot;template_id&quot;: &quot;YOUR_TEMPLATE_ID&quot;}' />
  <input type="file" name="myfile_1" multiple="multiple" />
  <input type="submit" value="Upload" />
</form>
Uppy
20% off any plan for the Uppy community
Use the UPPY20 code when upgrading.
Sign up
tus
20% off any plan for the tus community
Use the TUS20 code when upgrading.
Sign up
Product Hunt
20% off any plan for Product Hunters
Use the PRH20 code when upgrading.
Sign up