File uploads for web forms

We believe in most cases you are better off using Uploadcare Widget or one of our API clients for all kinds of uploads.

If you don’t want those, there is a way to route your web forms through Uploadcare, so that we upload files submitted with your form and resend that form with no actual files but their UUIDs to a URL of your choice. All you have to do is point your form’s action attribute to https://upload.uploadcare.com/submit/ and place your initial action value in a hidden field named UPLOADCARE_ACTION.

POST /submit/

Request parameters

UPLOADCARE_PUB_KEY, string

Defines a target project your uploads will go to, by its public key.

UPLOADCARE_ACTION

Sets the URL to resubmit your form with file UUIDs to.

If UPLOADCARE_ACTION is missing, the method returns an error:

[HTTP 400] UPLOADCARE_ACTION is required.

If your provided URL is invalid, the method returns an error:

[HTTP 400] UPLOADCARE_ACTION should be a valid URL.

UPLOADCARE_STORE

Sets the file storing behavior. Once stored, files are not deleted after a 24-hour period. Accepted values are:

  • 0 or not set — files do not get stored upon uploading.
  • 1 — files get stored upon uploading. Requires the “automatic file storing” setting to be enabled.
  • auto — file storing works in line with your project settings.

(other)

Any other form fields, including files. Any field names are valid. All file fields are replaced with their respective UUIDs on form resend.

Example

Here is a basic setup to use the feature:

<form method="POST" enctype="multipart/form-data"
      action="https://upload.uploadcare.com/submit/">

  <input type="hidden" name="UPLOADCARE_PUB_KEY" value="demopublickey">
  <input type="hidden" name="UPLOADCARE_ACTION" value="https://my-app.com/my-form-handler/">
  <input type="file" name="my-file">
</form>

We’re always happy to help with code, integration, and other stuff. Search our site for more info or post your question in our Community Area.