v0.9.0-rc
This commit is contained in:
32
common/Controller/Web/Admin/Documentos.php
Normal file
32
common/Controller/Web/Admin/Documentos.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
namespace ProVM\NotariaRaby\Common\Controller\Web\Admin;
|
||||
|
||||
use Psr\Container\ContainerInterface as Container;
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
use Psr\Http\Message\ResponseInterface as Response;
|
||||
use ProVM\Common\Service\Filemanager;
|
||||
|
||||
class Documentos {
|
||||
public function upload(Request $request, Response $response, Filemanager $filemanager, Container $container): Response {
|
||||
$post = $request->getParsedBody();
|
||||
$files = $request->getUploadedFiles();
|
||||
$file = $files['archivo'];
|
||||
|
||||
$filename = implode(DIRECTORY_SEPARATOR, [
|
||||
$container->get('folders.upload'),
|
||||
$post['filename'] . '.pdf'
|
||||
]);
|
||||
$file->moveTo($filename);
|
||||
$status = (file_exists($filename) and filemtime($filename) == time());
|
||||
|
||||
$output = [
|
||||
'informacion' => $post,
|
||||
'estado' => $status,
|
||||
'archivo' => $filename
|
||||
];
|
||||
$response->getBody()->write(json_encode($output));
|
||||
return $response
|
||||
->withHeader('Content-Type', 'application/json')
|
||||
->withStatus(201);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user