Private files
Theprivate 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
/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 ofmultiple fields. Keep them with:
app/Models/Invoice.php
reduce_space to false.
Image compression and maximum size
Uploadedjpg, jpeg and png images are post-processed:
- rotated by EXIF orientation,
- resized when larger than
image_max_width×image_max_height(3840 × 2160 by default, the ratio is kept), - JPEG images are encoded with the
image_lossy_compression_qualityquality (85 by default), - optimized by shell tools (
jpegoptim,optipng,pngquant, …) whenimage_lossless_compressionis enabled.
app/Models/Gallery.php
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
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. Defineget{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