Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
composing objects and make methods and objects testable
<?php
require_once __DIR__ . '/../vendor/autoload.php';
$uploadHandler = new \Acme\FileUpload\UploadHandler();
$uploadHandler
->setFormFieldName('upload')
->setTargetDirectory(__DIR__ . '/../uploads')
->addValidator(new JpegFileTypeValidator())
->addValidator(new maxFileSizeValidator(4096))
->addValidator(new fileExistsValidator()); // don't overwrite existing uploads
// ...
$uploadHandler->handle($_FILES);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.