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

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -