Skip to content

Temporary Uploads ​

Temporary uploads are the default:

php
use InertiaUI\Forms\Fields\File;

File::make('avatar');

Selecting a file starts the following flow:

  1. The frontend field posts the file to POST /_inertia-forms/file-upload.
  2. Laravel stores the file temporarily and validates the upload-time file rules.
  3. The endpoint returns JSON with a key.
  4. The form stores that key instead of the raw browser file.
  5. A request macro decrypts the named key on first read and exposes the resolved upload as a SubmittedUpload. A FormRequest implementing HasUploads may eager-hydrate upload keys from its rules.

The endpoint response looks like this:

json
{
    "key": "encrypted-temporary-upload-token",
    "name": "avatar.jpg",
    "mimeType": "image/jpeg",
    "mime_type": "image/jpeg",
    "size": 12345
}

The key value is the submitted form value. A multiple field submits an array of keys.

Store With The Form ​

The storeWithForm method sends a newly selected file with the final Inertia form request:

php
File::make('document')->storeWithForm();

This fits small create forms that don't need existing file preservation, preview tokens, or Media Library synchronization. In this mode, Laravel receives native multipart File values with the normal form submission, and all validation runs at submit time. You may read the file with $request->file('document'). The Form upload helpers return null, because there is no temporary upload token to resolve:

php
namespace App\Http\Controllers;

use App\Forms\DocumentForm;
use Illuminate\Http\Request;
use InertiaUI\Forms\Validate;

class DocumentController extends Controller
{
    public function store(Request $request, #[Validate] DocumentForm $form)
    {
        $path = $request->file('document')?->store('documents', 'public');
    }
}

Custom Temporary Endpoint ​

To post selected files to your own endpoint, pass its URL to the temporaryUploadUrl method:

php
File::make('avatar')->temporaryUploadUrl('/uploads/avatar');

Your endpoint receives multipart data with the file in the file field. It should return the submitted value as key, path, url, or id. The key property is recommended because it matches the built-in endpoint.

A custom endpoint has no package token guard by default. An endpoint that returns Inertia Forms temporary upload tokens with the expected validation hash may opt into that token guard:

php
File::make('avatar')
    ->temporaryUploadUrl('/uploads/avatar')
    ->requireValidatedUploads();

Upload Concurrency ​

A field uploads up to three files at a time and queues the rest. You may change the limit using the concurrentUploads method:

php
File::make('photos')
    ->multiple()
    ->concurrentUploads(1); // one file at a time

The limit applies to temporary, chunked, and direct-to-storage uploads.