public function saveUploadedFile($input)
{
$file = array_get($input, 'file', null);
if (is_null($file)) {
return false;
}
$originalName = $file->getClientOriginalName();
$localPath = isset($input['category']) ? $this->CategoryPaths->fromDot($input['category']) : '';
$serverPath = $this->CategoryPaths->serverPath($localPath);
$newName = $this->createFile($file, $serverPath, $originalName);
if ($this->Image->canMakeThumbnailFromFile($file)) {
$thumbnailPath = $this->getThumbnailPath($localPath . '/' . $newName);
if (!is_dir(dirname($thumbnailPath))) {
mkdir(dirname($thumbnailPath), 0755, true);
}
$this->Image->makeThumbnailImage($serverPath . $newName, $thumbnailPath, $file->getClientMimeType());
}
return $localPath . '/' . $newName;
}