Temporary Uploads
Temporary uploads are the default:
use InertiaUI\Forms\Fields\File;
File::make('avatar');Selecting a file starts the following flow:
- The frontend field posts the file to
POST /_inertia-forms/file-upload. - Laravel stores the file temporarily and validates the upload-time file rules.
- The endpoint returns JSON with a
key. - The form stores that key instead of the raw browser file.
- A request macro decrypts the named key on first read and exposes the resolved upload as a
SubmittedUpload. AFormRequestimplementingHasUploadsmay eager-hydrate upload keys from its rules.
The endpoint response looks like this:
{
"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:
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:
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:
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:
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:
File::make('photos')
->multiple()
->concurrentUploads(1); // one file at a timeThe limit applies to temporary, chunked, and direct-to-storage uploads.