Cloudinary File Uploads

All the file inputs in Laratic are powered by Cloudinary using their hosted widget and cloudinay laravel package.

Cloudinary prerequisites

  1. Create a free Cloudinary account at cloudinary.com.
  2. Go to Settings > API Keys, create a new API key and copy your Cloud Name, API Key, and API Secret.
  3. In your Cloudinary Console, open Settings > Upload > Upload presets and create an unsigned preset for your application.

Recommended upload preset

  • Name: something descriptive like laratic_unsigned
  • Signing Mode: Unsigned
  • Folder: optional (for example laratic/uploads)
  • Allowed formats: include the image/video types you plan to support

Save the preset ID because the widget references it through CLOUDINARY_UPLOAD_PRESET.

.env configuration

Add or update the following environment variables, then run php artisan config:cache:

CLOUDINARY_URL=cloudinary://your-api-key:your-api-secret@your-cloud-name
CLOUDINARY_UPLOAD_PRESET=

These values feed config/cloudinary.php and the Cloudinary filesystem disk so the widget can generate signed URLs automatically.

Using the admin upload page

  1. Visit /admin/files/upload (route name admin.files.upload).
  2. Click “Choose a file to upload” to open the Cloudinary widget.
  3. Select your local file. Once the upload finishes, the page shows a success card, the hosted URL, and a copy shortcut.
  4. If the file is an image, Laratic renders a live preview. Non-image files simply show the URL.

References

Category Path / Name Description
Route GET /admin/files/upload (admin.files.upload) Admin page that renders the Livewire component
Livewire App\Livewire\Admin\FileUpload Stores the uploaded URL and returns the view
View resources/views/livewire/admin/file-upload.blade.php UI for the uploader, copy button, and preview
Component resources/views/components/input-file.blade.php Wraps Cloudinary’s widget and syncs with Livewire
Config config/cloudinary.php Reads environment variables for Cloudinary credentials