Skip to content

Setup: Upload

dante di domenico edited this page Jun 12, 2024 · 2 revisions

Edit configuration

Upload settings can be set by uploadAccepted, uploadForbidden and uploadMaxResolution configurations in config/app_local.php (or in config/projects/<projectName>.php if you use multi project configuration).

I.e.:

'uploadAccepted' => [
    // ...
],
'uploadForbidden' => [
    // ...
],
'uploadMaxResolution' => '1920x1080',

Upload accepted

uploadAccepted is used to specify mime types accepted per object type, in form upload input files. In the following example, input file accepts:

  • audio/* for objects of type Audio
  • image/* for objects of type Images
  • video/* for objects of type Videos
'uploadAccepted' => [
    'audio' => [
        'audio/*',
    ],
    'images' => [
        'image/*',
    ],
    'videos' => [
        'video/*',
    ],
],

Upload forbidden

uploadForbidden configuration is used to forbid from upload specific mime types and/or file extensions. I.e.:

'uploadForbidden' => [
    'mimetypes' => [
        'application/javascript',
        'application/x-cgi',
        'application/x-perl',
        'application/x-php',
        'application/x-ruby',
        'application/x-shellscript',
        'text/javascript',
        'text/x-perl',
        'text/x-php',
        'text/x-python',
        'text/x-ruby',
        'text/x-shellscript',
    ],
    'extensions' => [
        'cgi',
        'exe',
        'js',
        'perl',
        'php',
        'py',
        'rb',
        'sh',
    ],
],

Upload max resolution

uploadMaxResolution is used to set the maximum resolution for images uploaded.

In the following example, the maximum resolution is set to 1920x1080.

'uploadMaxResolution' => '1920x1080',