Skip to content

Configuration ​

Publishing The Config File ​

Inertia Forms works without a configuration file. To change its defaults, publish the configuration file to your application's config directory:

bash
php artisan vendor:publish --tag=inertia-forms-config

This creates config/inertia-forms.php with all available options. See Installation for the setup command in context.

File Uploads ​

Upload configuration is grouped by responsibility:

  • temporary_uploads is the staging area for uploads that Laravel receives before the form is submitted. This includes the default temporary upload endpoint and optional chunked uploads.
  • direct_to_storage is for uploads where the browser sends file bytes directly to a Laravel filesystem disk backed by S3-compatible object storage.
  • existing_files controls the lifetime of encrypted keys for files already attached to a model.
  • cleanup_disks adds per-field disks to the temporary upload cleanup command.

All max_size values are in kilobytes, matching Laravel's max: file validation rule. Chunk, part, and multipart threshold values are in bytes, because the browser and S3 APIs work in bytes.

php
return [
    'file_uploads' => [
        'route_prefix' => '/_inertia-forms',
        'route_name' => 'inertia-forms.',
        'middleware' => ['web', 'auth'],

        'temporary_uploads' => [
            'disk' => '',
            'lifetime' => 3600, // seconds
            'max_size' => 10240, // 10 MB in kilobytes

            'chunked' => [
                'size' => 5 * 1024 * 1024, // 5 MB in bytes
                'max_size' => 2 * 1024 * 1024, // 2 GB in kilobytes
            ],
        ],

        'direct_to_storage' => [
            'disk' => '',
            'url_lifetime' => 900, // seconds
            'part_size' => 16 * 1024 * 1024, // 16 MB in bytes
            'multipart_threshold' => 100 * 1024 * 1024, // 100 MB in bytes
            'max_size' => 5 * 1024 * 1024, // 5 GB in kilobytes
        ],

        'existing_files' => [
            'lifetime' => 3600, // seconds
        ],

        'cleanup_disks' => [],
    ],
];

Routes ​

The file_uploads.route_prefix option controls the URL prefix for the built-in upload endpoints, and file_uploads.route_name controls their route name prefix. The file_uploads.middleware option controls the middleware applied to those endpoints:

php
return [
    'file_uploads' => [
        'route_prefix' => '/_inertia-forms',
        'route_name' => 'inertia-forms.',
        'middleware' => ['web', 'auth'],
    ],
];

You may add your own middleware to this list. For example, you might add a throttle middleware to limit upload frequency.

For separate application sections, register additional upload route groups and point fields at them with uploadRoutes(). See File Upload Routes for the route group example and naming rule.

Temporary Uploads ​

The file_uploads.temporary_uploads.disk option controls the staging disk that temporary uploads use before the form is submitted. An empty value creates a local disk at storage/inertia-forms-temporary-uploads:

php
return [
    'file_uploads' => [
        'temporary_uploads' => [
            'disk' => '',
        ],
    ],
];

To stage temporary uploads somewhere else, set this option to any disk defined in config/filesystems.php. This doesn't decide where your application stores the final file. Your controller, Media Library sync, or other application code still chooses the final destination later.

The file_uploads.temporary_uploads.lifetime option controls how long a temporary upload is kept before cleanup, in seconds. The file_uploads.temporary_uploads.max_size option is the maximum file size, in kilobytes, that the built-in temporary upload endpoint accepts:

php
return [
    'file_uploads' => [
        'temporary_uploads' => [
            'lifetime' => 3600,
            'max_size' => 10240,
        ],
    ],
];

Individual fields may set their own maxSize() rules. Those field rules are validated separately during upload.

Chunked Temporary Uploads ​

The file_uploads.temporary_uploads.chunked.size option is the default and maximum chunk size, in bytes, for fields using chunked(). The file_uploads.temporary_uploads.chunked.max_size option is the maximum declared file size, in kilobytes, that the chunked upload endpoint accepts. Its default is 2 GB:

php
return [
    'file_uploads' => [
        'temporary_uploads' => [
            'chunked' => [
                'size' => 5 * 1024 * 1024,
                'max_size' => 2 * 1024 * 1024,
            ],
        ],
    ],
];

Fields may lower the chunk size with chunked(size: 2 * 1024 * 1024). A larger field size is capped at the configured value.

Direct To Storage ​

The file_uploads.direct_to_storage.disk option is the Laravel filesystem disk used when a field calls directToStorage() without a disk name. The value should be a disk from config/filesystems.php, the same name you would pass to Storage::disk():

php
return [
    'file_uploads' => [
        'direct_to_storage' => [
            'disk' => '',
        ],
    ],
];

An empty value uses the s3 disk. Fields may override the disk with directToStorage('minio') or uploadDisk('minio').

Inertia Forms infers the upload implementation from the Laravel filesystem disk driver. Disks using Laravel's s3 filesystem driver use the built-in S3-compatible upload driver. Local disks are supported for tests and local same-origin endpoint coverage. For large local uploads in your application, prefer chunked().

The file_uploads.direct_to_storage.url_lifetime option controls how long signed storage URLs remain valid, in seconds:

php
return [
    'file_uploads' => [
        'direct_to_storage' => [
            'url_lifetime' => 900,
        ],
    ],
];

The file_uploads.direct_to_storage.part_size option is the default multipart part size, in bytes. The file_uploads.direct_to_storage.multipart_threshold option is the file size, in bytes, above which direct-to-storage uploads use multipart mode. Files at or below this threshold use a single signed PUT:

php
return [
    'file_uploads' => [
        'direct_to_storage' => [
            'part_size' => 16 * 1024 * 1024,
            'multipart_threshold' => 100 * 1024 * 1024,
        ],
    ],
];

Fields may override these values with partSize() and multipartThreshold().

The file_uploads.direct_to_storage.max_size option is the maximum declared file size, in kilobytes, that the direct upload endpoint accepts. Its default is 5 GB:

php
return [
    'file_uploads' => [
        'direct_to_storage' => [
            'max_size' => 5 * 1024 * 1024,
        ],
    ],
];

Existing Files ​

The file_uploads.existing_files.lifetime option controls how long an encrypted existing file key remains valid, in seconds. The default is one hour:

php
return [
    'file_uploads' => [
        'existing_files' => [
            'lifetime' => 3600,
        ],
    ],
];

You may raise this value for forms that stay open longer. Published config files without this key fall back to file_uploads.temporary_uploads.lifetime.

Cleanup Disks ​

The file_uploads.cleanup_disks option lists additional Laravel filesystem disks for the form:cleanup-uploads command to sweep. Add each per-field disk used by directToStorage('disk') or uploadDisk('disk') that differs from the global direct-to-storage disk:

php
return [
    'file_uploads' => [
        'cleanup_disks' => ['media', 'documents'],
    ],
];

A per-field disk that isn't covered logs one warning during serialization. See Which Disks Are Swept for the cleanup rules and command options.

Authorization ​

The authorization options control how a form behaves once it fails its authorization check.

authorization.throw_on_unauthorized ​

With false, the default, an unauthorized form returns an empty structure. With true, it throws a 403 AuthorizationException. Unauthorized fields are always omitted without an error, regardless of this setting:

php
return [
    'authorization' => [
        'throw_on_unauthorized' => false,
    ],
];

Full Default Configuration ​

The published config/inertia-forms.php file contains the following defaults:

php
return [
    'file_uploads' => [
        'route_prefix' => '/_inertia-forms',
        'route_name' => 'inertia-forms.',
        'middleware' => ['web', 'auth'],

        'temporary_uploads' => [
            'disk' => '',
            'lifetime' => 3600, // seconds
            'max_size' => 10240, // 10 MB in kilobytes

            'chunked' => [
                'size' => 5 * 1024 * 1024, // 5 MB in bytes
                'max_size' => 2 * 1024 * 1024, // 2 GB in kilobytes
            ],
        ],

        'direct_to_storage' => [
            'disk' => '',
            'url_lifetime' => 900, // seconds
            'part_size' => 16 * 1024 * 1024, // 16 MB in bytes
            'multipart_threshold' => 100 * 1024 * 1024, // 100 MB in bytes
            'max_size' => 5 * 1024 * 1024, // 5 GB in kilobytes
        ],

        'existing_files' => [
            'lifetime' => 3600, // seconds
        ],

        'cleanup_disks' => [],
    ],

    'authorization' => [
        'throw_on_unauthorized' => false,
    ],
];

Using Environment Variables ​

The published config uses literal defaults. To drive a value from the environment, you may replace it with env(...) in your own config/inertia-forms.php file.