<CldUploadWidget />
The CldUploadWidget
creates a new instance of the Cloudinary upload widget giving you an easy way to add upload capabilities to your Svelte app.
The widget will not render any UI by default, instead needing to have the open
function called. The simplest way to do this is to nest a button inside a slot and use the open
slot prop. There are two options when using the CldUploadWidget: signed and unsigned. These options allow you to control the amount of security and restrictions you place on uploads.
Unsigned
Providing that unsigned uploads are allowed for your uploadPreset
you can simply do:
Signed
Signing upload requests require a signature endpoint which uses your Cloudinary secret key to sign the upload request. The following example uses SvelteKit but you can use any server framework to write this:
You’ll need to make sure you’ve configured a Cloudinary API key both on client and server. Read more about configuring Svelte Cloudinary here.