public function upload(UploadedFile &$file)
{
// Check the upload type is valid by extension and mimetype
$this->verifyUploadType($file);
// Get the folder for uploads
$folder = $this->getUploadFolder();
// Check file size
if ($file->getSize() > static::$app['config']->get('cabinet::max_upload_file_size')) {
throw new FileException('File is too big.');
}
// Check to see if file exists already. If so append a random string.
list($folder, $file) = $this->resolveFileName($folder, $file);
// Upload the file to the folder. Exception thrown from move.
$file->move($folder, $file->fileSystemName);
// If it returns an array it's a successful upload. Otherwise an exception will be thrown.
return array($this->cleanPath(static::$app['config']->get('cabinet::upload_folder')) . $this->dateFolderPath, $file->fileSystemName);
}