Skip to content

Files and exports

Option Default Purpose
$fileMaxSize 10 MB maximum size of an upload in bytes
$fileTypes PDF, PNG, JPEG, GIF, WebP, TXT, CSV, DOCX, XLSX, PPTX, ODT, ODS allowed uploads: extension => [MIME types]
$filePath null → WRITEPATH/anvil/files directory of stored files, outside the web root
$fileScanner null virus scanner class, e.g. Anvil\Files\ClamAvScanner::class
$clamAvSocket unix:///var/run/clamav/clamd.ctl socket of clamd, also tcp://127.0.0.1:3310
public int $fileMaxSize = 25 * 1024 * 1024;
public array $fileTypes = [
'pdf' => ['application/pdf'],
'png' => ['image/png'],
'jpg' => ['image/jpeg'],
'jpeg' => ['image/jpeg'],
'dwg' => ['image/vnd.dwg', 'application/acad'],
];
public ?string $fileScanner = \Anvil\Files\ClamAvScanner::class;
public string $clamAvSocket = 'tcp://127.0.0.1:3310';
  • The extension and the MIME type detected from the content must match an entry. SVG and HTML are not allowed by default (scripts).
  • Setting $fileTypes replaces the list: repeat the types you keep.
  • With a scanner, uploads are rejected when it finds something or cannot be reached (fail closed).
  • PHP and the web server must accept the size as well, see Maximum file size.
  • Keep $filePath on a backed up volume, outside the web root.

Details: Files and attachments.

Option Default Purpose
$exportSyncLimit 1000 up to this number of rows the file is created right away; more rows go to the queue
$exportMaxRows 100000 upper limit of one export
$exportTtl 86400 seconds an export can be downloaded
$exportQueue 'anvil' queue of large exports
$exportPath null → WRITEPATH/anvil/exports directory of export files, outside the web root
  • Large exports need a queue worker: php spark queue:work anvil; the user is notified when the file is ready.
  • Expired files are deleted by php spark anvil:prune.

Details: Exports.