Witam,
Z pomocą frameworka Phalcon próbuje zwrócić zdjęcie w kontrolerze.
Oto funkcja w klasie.
public static function downloadByUri() {
$component = new Component();
$params = $component->dispatcher->getParams();
$hash = (string) \array_shift($params);
$file = self::getFile($hash);
$response = new Response();
if ($file instanceof SiteFiles) {
$dir = realpath('./data') . DIRECTORY_SEPARATOR . $file->filePath . "." . $file->fileExtenstion;
if (file_exists($dir)) {
$response->setContentType($file->fileMimeType);
$response->setStatusCode(200, 'Ok');
$response->setHeader("Cache-Control", "private, max-age=86400");
$response->setHeader('X-Sendfile', $dir);
$response->send();
} else {
$response->setStatusCode(404, 'Not found');
}
} else {
$response->setStatusCode($file[0], $file[1]);
}
return $response;
}
A to jej wywołanie w kontrolerze
class FileController extends BaseController {
public function initialize() {
parent::initialize();
}
public function getAction(){
return FilesDownload::downloadByUri();
}
}
Ścieżka jest prawidłowa, serwer zwraca kod 200, mimo tego zdjęcie się nie wyświetla.Co może być nie tak?
Pozdrawiam