php - force download on restler function call -
i got following function in restler
/** * updatefiles name * * 1 last update file * * @status 201 * @return file */ function getupdatefile($filename) { $file = 'plakat.jpg'; if (file_exists($file)) { header('content-description: file transfer'); header('content-type: application/octet-stream'); header('content-disposition: attachment; filename='.basename($file)); header('content-transfer-encoding: binary'); header('expires: 0'); header('cache-control: must-revalidate'); header('pragma: public'); header('content-length: ' . filesize($file)); ob_clean(); flush(); readfile($file); exit; } else { return "<h1>content error</h1><p>the file not exist!(".dirname(__file__).'/'.($file).")</p>"; } }
the problem file there permissions correct no file download forced. failure? return "the file not exist does. searched different problems force download php seems problem restler?
thx ingo
you can try code below happens work fine
$file = 'plakat.jpg'; if(file_exists($file)) { header("content-type: image/png"); header('content-disposition: attachment; filename="imagename.png"'); header("content-type: application/force-download"); header("content-type: application/octet-stream"); header("content-type: application/download"); readfile($file); } exit();
Comments
Post a Comment