File fields and their parameters are described in File uploads. This page covers the upload behaviour of the whole model.

Private files

The private field parameter stores a file outside the public directory. To make all file fields of a model private, set the property:
app/Models/Contract.php
In the administration, private files are served through /uploads/{table}/{field}/{filename} only to logged administrators with the read permission of the model. A guest receives 401. On the website use the signed download() link.

Deleting old files

When a file is replaced in the form, or a record is deleted, the original files are deleted from the storage, including files of multiple fields. Keep them with:
app/Models/Invoice.php
Resized copies of images in the cache are removed in both cases. To keep the files of all models, set reduce_space to false.

Image compression and maximum size

Uploaded jpg, jpeg and png images are post-processed:
  1. rotated by EXIF orientation,
  2. resized when larger than image_max_width × image_max_height (3840 × 2160 by default, the ratio is kept),
  3. JPEG images are encoded with the image_lossy_compression_quality quality (85 by default),
  4. optimized by shell tools (jpegoptim, optipng, pngquant, …) when image_lossless_compression is enabled.
Every step can be changed per model:
app/Models/Gallery.php
The global defaults are described in the configuration.

Uploading files from code

upload($field, $file, $options = []) stores a file into the directory of a model field, runs the same image processing as the administration and returns the file object. The column value is not changed, assign the filename yourself.
app/Http/Controllers/ProfileController.php
The second argument accepts an UploadedFile, a path to a local file (the source file is copied) or a URL. When the upload fails, upload() returns false and getUploadError() returns the reason. Filenames are slugged and an existing file is never overwritten (invoice-1.pdf). The filename can be changed by the set{Key}Filename() method of the model.

Thumbnail size in the table

Image thumbnails in the table are 50×50 px. Define get{Field}AdminThumbnailDimensions(), with the field key in camel case, to change the size. Use null for one side to keep the ratio.
app/Models/Product.php

Editor file manager folder

With a file browser enabled, editor uploads go into the storage folder of the record. setFieldUploader() changes the folder config for a field.
app/Models/Article.php