Skip to content

Instantly share code, notes, and snippets.

@xiaohutai
Forked from rossriley/uploadSanitiser.php
Last active January 26, 2018 12:42
Show Gist options
  • Save xiaohutai/f4315e6b77b5ae38637c8919e564265d to your computer and use it in GitHub Desktop.
Save xiaohutai/f4315e6b77b5ae38637c8919e564265d to your computer and use it in GitHub Desktop.
Bolt: Extending the upload handler with custom sanitiser
$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;
}
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment