$this->
View()->
assign(['success' => true
]);
} /**
* @throws Exception
*/
private function prepareUploadedFile(array
$params): array
{ // Check for a POSTed file
if ($this->
Request()->files->
has('file'
)) { $file =
$this->
Request()->files->
get('file'
);
$fileExtension =
$file->
getClientOriginalExtension();
$fileName =
$file->
getClientOriginalName();
if ($file->
getError() !== UPLOAD_ERR_OK
) { throw new \
Exception(sprintf('Could not upload file "%s"',
$file->
getClientOriginalName()));
} // use custom name if provided
if (!
empty($params['name'
])) { // Use the provided name to overwrite the file name, but keep the extensions to allow
// automatic detection of the file type
$fileName =
$params['name'
] . '.' .
$fileExtension;
}