Portable and a little bit simpler :

protected function sendFile($response,$contentType,$filePath)
{
  $response = $this->getResponse();
  $file = sfConfig::get('sf_root_dir').'/[dir]/'.$filePath; // [dir]
is inaccessible from the web

  if(is_file($file))
  {
    $response->setHttpHeader('Content-Type', $contentType);
    $response->setHttpHeader('Content-Length', filesize($file));
    $response->setHttpHeader('Last-Modified', gmdate("D, d M Y H:i:s",
filemtime($file)).' GMT');
    $response->sendHttpHeaders(); // send the headers before the file
data
    $response->setContent(readfile($file));
  }

  return sfView::NONE;
}

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to