uploadcaredocs

JavaScript API reference

  • This documentation is for the version 3.6.1 of the widget. If you're looking for the JavaScript for Widget v2 docs, check here.

Our JavaScript API is an extensive set of tools allowing you to adjust the widget behavior and implement advanced worfkflows like uploading files from URL, moderating uploaded content, and playing with the widget appearance. You can use it with or without the widget, as standalone components.

It is important to note that as stated in the Widget Configuration section, widget options can be set in three ways.

  • Globally, on page load.
  • Locally, when a new widget is created.
  • By passing the settings object.

JavaScript global variables are put in your <script> tag,

<script>
  UPLOADCARE_PUBLIC_KEY = 'demopublickey';
  UPLOADCARE_LOCALE = 'ru';
</script>

Local options are set in the <input> element as data attributes,

<input type="hidden" role="uploadcare-uploader"
  data-public-key="demopublickey"
  data-images-only
/>

You can also pass most of the widget options as an argument holding the settings object to the methods listed in this JavaScript API reference. For instance,

uploadcare.openDialog(null, {
  publicKey: 'demopublickey',
  imagesOnly: true,
  crop: '300x200'
});

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.