Quick Start Guide
This guide will help you set up a working file uploader in minutes. By the end, you’ll have a fully functional upload form ready to accept files.Prerequisites
Before you begin, you’ll need:- An Uploadcare account (sign up for free)
- Your Public API key from the Uploadcare dashboard
Installation
First, install File Uploader:Basic Setup
Follow these steps to create your first uploader:Import and define components
In your JavaScript file, import File Uploader and define the web components:The
defineComponents() function registers all File Uploader components as custom elements.Add uploader to your HTML
Add the uploader component and configuration to your HTML:Replace
YOUR_PUBLIC_KEY with your actual Public API key from Uploadcare.The
ctx-name attribute links the uploader and config together. Use the same value for both components.Complete Example
Here’s a complete working example:Using the Inline Uploader
For a different layout, try the inline uploader that’s always visible on the page:Handling Upload Events
To handle uploaded files, listen for events using the Upload Context Provider:The
change event fires whenever the upload state changes. Use successEntries to access successfully uploaded files.Common Configuration Options
Customize your uploader with configuration attributes:Multiple Files
Images Only
File Size Limit
Specific File Types
Custom Upload Sources
local, url, camera, dropbox, gdrive, gphotos, instagram, facebook, onedrive, box, vk, evernote, flickr, huddle
Getting File Information
When a file is successfully uploaded, you receive anOutputFileEntry object with comprehensive information:
uuid- Unique file identifiercdnUrl- Direct URL to access the filename- Original filenamesize- File size in bytesfileInfo- Complete file metadata from Uploadcare API
Using Uploaded Files
Once uploaded, use thecdnUrl to display or download files:
Display an Image
Apply Image Transformations
Uploadcare provides URL-based image transformations:Debugging
Enable debug mode to see detailed logs in the console:Debug mode logs configuration changes, upload progress, and error details. Disable it in production.
Troubleshooting
Components Not Rendering
Make sure you’ve calleddefineComponents() before the HTML is parsed:
CSS Not Loading
Import the CSS file in your JavaScript:“Invalid public key” Error
Verify your public key:- Check for typos in the
pubkeyattribute - Ensure you’re using the Public Key, not the Secret Key
- Confirm the key is from the correct Uploadcare project
CORS Errors
Uploadcare handles CORS automatically. If you see CORS errors, check:- You’re using a valid public key
- Your domain is not blocked in Uploadcare project settings
Next Steps
Now that you have a working uploader, explore more features:Configuration
Explore all configuration options
Customization
Customize the appearance
Events
Handle upload events
Validation
Add file validation rules