//dump($kernel->getBasePath());die;
//dump($this->get('kernel')->getRootDir() . '/../public_html');die;
//$path = $kernel->locateResource('@AppBundle/Resources/public/info/' . $filename);
$ipaddress = $this->get('kernel')->getRootDir() . '/../web';
$path = $ipaddress . '/uploads/articole/attachments/' . $filename;
$content = file_get_contents($path);
$response = new \Symfony\Component\HttpFoundation\Response();
$response->setStatusCode(200);
$response->headers->set('Content-Type', 'application/pdf');
$response->headers->set('Content-Disposition', sprintf('attachment;filename=""'.$filename));
$this->dispatcher->dispatch(KernelEvents::CONTROLLER_ARGUMENTS, $event);
$controller = $event->getController();
$arguments = $event->getArguments();
// call controller
$response = \call_user_func_array($controller, $arguments);
// view
if (!$response instanceof Response) {
$event = new GetResponseForControllerResultEvent($this, $request, $type, $response);
$this->dispatcher->dispatch(KernelEvents::VIEW, $event);
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
$request->headers->set('X-Php-Ob-Level', ob_get_level());
try {
return $this->handleRaw($request, $type);
} catch (\Exception $e) {
if ($e instanceof RequestExceptionInterface) {
$e = new BadRequestHttpException($e->getMessage(), $e);
}
if (false === $catch) {
//$kernel = new AppCache($kernel);
// When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter
//Request::enableHttpMethodParameterOverride();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
No log messages
ContextErrorException |
---|
Symfony\Component\Debug\Exception\ContextErrorException: Warning: file_get_contents(/home/primariacraiova/public_html/app/../web/uploads/articole/attachments/6142f61528df6508812201.pdf): failed to open stream: No such file or directory at src/AppBundle/Controller/DefaultController.php:224 at AppBundle\Controller\DefaultController->infoDownloadAction('6142f61528df6508812201.pdf') (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:151) at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1) (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:68) at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true) (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:169) at Symfony\Component\HttpKernel\Kernel->handle(object(Request)) (web/app.php:19) |