On Tue, Mar 24, 2009 at 5:46 PM, Tomasz Ignatiuk <[email protected]>wrote:
> I opened with a VIM. Many strange alphanumeric stuff inside but in the end > there is a warning few times: > > > <b>Warning</b>: Cannot modify header information - headers already sent by > (output started at > /home/..../apps/backend/modules/dokument/actions/actions.class.php:592) in > <b>/home/../symfony/1.2/lib/response/sfWebResponse.class.php</b> on line > <b>335</b><br / > > 592 line is: $response->setContent(readfile($sciezka)); > Try to export without the _dev frontend enabled. > > > > > > 2009/3/24 Yevgeniy A. Viktorov <[email protected]> > > >> >> Open it as raw file, for example with the help of "vim". >> >> Tomasz Ignatiuk wrote: >> > "File is damaged and it couldn't be repaired" - this shows while I try >> > to open it with adobe acrobat/reader. I don;t know how to check it in >> > a different way. >> > >> > 2009/3/24 Fási Gábor <[email protected] <mailto:[email protected]>> >> > >> > What's 'broken'? You mean you can't open it with adobe reader/other >> > pdf viewer? If you check the contents of the file, does it look like >> a >> > valid pdf? >> > >> > On Tue, Mar 24, 2009 at 12:51, Tomasz Ignatiuk >> > <[email protected] <mailto:[email protected]>> wrote: >> > > >> > > Hi, I use this code for downloading files. If I download image, it >> > > works, but if I download pdf, after downloading when I try to >> > open it, >> > > it is broken. >> > > >> > > if (is_file($sciezka)) >> > > { >> > > // Enforce full download >> > and prevent caching >> > > >> > session_cache_limiter('none'); >> > > >> > > // No layout needed for >> > file downloads >> > > $this->setLayout(false); >> > > >> > sfConfig::set('sf_web_debug', false); >> > > >> > > // Prepare http headers >> > > $fileType = >> > $file->getFormat()->getNazwa(); >> > > >> > > $response = >> > $this->getResponse(); >> > > >> > $response->clearHttpHeaders(); >> > > >> > $response->setHttpheader('Pragma: public', true); >> > > >> > $response->addCacheControlHttpHeader('Cache-Control', 'must- >> > > revalidate'); >> > > >> > $response->setHttpHeader('Expires', 'Sat, 26 Jul 1997 05:00:00 >> > > GMT'); >> > > >> > $response->setHttpHeader("Last-Modified", gmdate("D, d M Y >> > > H:i:s") . " GMT"); >> > > >> > $response->setContentType($fileType,true); >> > > >> > $response->setHttpHeader('Content-Description', 'File Transfer'); >> > > >> > $response->setHttpHeader('Content-Transfer-Encoding', 'binary', >> > > true); >> > > >> > $response->setHttpHeader('Content-Length', filesize('' . (string) >> > > utf8_decode($sciezka . ''))); >> > > >> > $response->setHttpHeader('Content-Disposition', 'attachment; >> > > filename=' . str_replace(" ", "_", utf8_decode($file- >> > >>getFileNazwaOrginalna())) ); >> > > >> > > // Unlock session in >> > order to prevent php session warnings >> > > >> $this->getUser()->shutdown(); >> > > >> > > // Send http headers to >> > user client >> > > >> $response->sendHttpHeaders(); >> > > >> > > // Send file to user client >> > > >> > //$response->setContent(readfile(utf8_decode($sciezka))); >> > > >> > $response->setContent(readfile($sciezka)); >> > > >> > //$response->setContent(file_get_contents(utf8_decode($file- >> > >>getPath()))); >> > > $response->sendContent(); >> > > >> > > // Exit without a template >> > > return sfView::NONE; >> > > >> > > >> > > This line gives a proper mime type >> > > $response->setContentType($fileType, true); >> > > >> > > fileType is taken from DB. These are: application/pdf and >> image/jpeg >> > > >> > > It is strange because locally on apache on windows it works, but >> not >> > > on production server. Locally when I upload file its pdf mime >> > type is >> > > application/x-download. On production server it is application/pdf >> > > >> > > Any ideas what is the problem? >> > > > >> > > >> > >> > >> > >> > >> > > >> >> >> > > > > -- Paolo Mainardi CTO Twinbit Blog: http://www.paolomainardi.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
