Public Upload Widget (Demo)

Back to Dashboard

Upload an Image (No Auth)

Notes: This calls the public endpoint directly and should not include any Authorization header. Uploads are rate-limited.

Copy-paste Snippet

async function publicUpload({ apiBase, projectPublicId, uploadPreset, file, apiKey }) {
  const url = apiBase + '/p/' + projectPublicId + '/images';
  const fd = new FormData();
  fd.append('upload_preset', uploadPreset);
  fd.append('file', file);
  if (apiKey) fd.append('api_key', apiKey);
  const res = await fetch(url, { method: 'POST', body: fd });
  if (!res.ok) throw new Error(await res.text());
  return res.json();
}