homeaboutvideotry it nowpricingdocs
Guide

Use Fileboy from Laravel: uploads, images and video

Install the official PHP package, upload from a controller, and show resized images from a stored ID.

Why use a hosted file service from Laravel

Your Laravel app can keep files on its own disk, or in a bucket it has to configure, secure and resize for. With Fileboy the app sends the file once, gets an ID back and keeps only that ID. Images are resized by changing a URL, so there is no image processing in your app, and the same ID works from any language.

1. Install the package

composer require fileboy/fileboy

You need a public key. Create a free app and copy it from the Keys page. Keep keys out of your code: read them from credentials or the environment.

2. Configure it once

app/Providers/AppServiceProvider.php
use Fileboy\Client;

public function register(): void
{
    $this->app->singleton(Client::class, fn () => new Client(
        publicKey: config('services.fileboy.public_key'),
        privateKey: config('services.fileboy.private_key'), // optional
    ));
}

// config/services.php
'fileboy' => [
    'public_key' => env('FILEBOY_PUBLIC_KEY'),
    'private_key' => env('FILEBOY_PRIVATE_KEY'),
],

3. Upload and keep the ID

Pass the uploaded file through. The call returns the file's details, and the id is the only thing to store.

app/Http/Controllers/AvatarController.php
use Fileboy\Client;
use Fileboy\Exception\FileboyException;
use Illuminate\Http\Request;

class AvatarController extends Controller
{
    public function store(Request $request, Client $fileboy)
    {
        $upload = $request->file('avatar');

        try {
            $file = $fileboy->uploadFile(
                $upload->getRealPath(),
                name: $upload->getClientOriginalName(),
                mime: $upload->getMimeType(),
            );
        } catch (FileboyException $e) {
            return back()->withErrors(['avatar' => $e->getMessage()]);
        }

        $request->user()->update(['avatar_fileboy_id' => $file->id]);

        return back();
    }
}
database/migrations/add_avatar_fileboy_id_to_users.php
Schema::table('users', function (Blueprint $table) {
    $table->string('avatar_fileboy_id')->nullable();
});

4. Show the image at the size you need

Build the URL from the stored ID. Asking for the size you display keeps pages light, and the original is never changed.

app/Models/User.php
use Fileboy\Client;

public function avatarUrl(int $size = 96): ?string
{
    if (! $this->avatar_fileboy_id) {
        return null;
    }

    return app(Client::class)->buildImageUrl($this->avatar_fileboy_id, transforms: [
        ['type' => 'resize', 'width' => $size * 2, 'height' => $size * 2, 'fit' => 'cover'],
        ['type' => 'format', 'format' => 'webp'],
    ]);
}

Reading a file or image needs no key, so these URLs work in <img> tags, emails and anywhere else, unless the app requires signed URLs. Uploads are what your key authorises.

Checked against the current libraries in November 2026. Found something that no longer works? Tell us.

Go deeper

Still choosing a tool?

Fileboy is small on purpose. This comparison says where it fits and where another option is the better call.

Fileboy vs S3 + Lambda · All comparisons

Try it

The free plan needs no card and includes 1,000 files, so you can run every example above.

More guides: How to add image upload to a React app · Resize images on the fly with a URL · Stream video with HLS without running ffmpeg · Add captions and subtitles to a video · All guides

Add Fileboy to your next project

We built Fileboy to stop rebuilding file handling for every app. Create an app, paste your key and upload a file. The free plan needs no card.