Bolt: Extending the upload handler with custom sanitiser

Xiao-Hu Tai
2018-01-26T12:41:03Z

uploadSanitiser.php

| $app['upload'] = $app->share(
| $app->extend(
| 'upload',
| function ($uploadHandler) {
|
| // Set max file size
| $uploadHandler->addRule('size', ['max' => '2M'])
|
| // Sanitize filename
| $uploadHandler->setSanitizerCallback(
| function ($filename) {
| // Do things with filename string here.
| return $filename;
| }
| );
|
| return $uploadHandler;
| }
| )
| );