Check that your file is valid ;) and use throw new sfStopException instead
of sfView::NONE.

2009/6/9 ctrlming <[email protected]>

>
> thank you, I tried many times , but the problem still exist.
> I think it`s not code`s problem,maybe something else.
>
> On 6月7日, 下午10时09分, Tomasz Ignatiuk <[email protected]> wrote:
> > This is my version which works form me:
> >
> >                     // 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(); //this
> > is my file type from db - for example application/pdf
> >                     $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($path_to_file. '')));
> >                     $response->setHttpHeader('Content-Disposition',
> > 'attachment; filename=' . str_replace(" ", "_",
> utf8_decode($file->getFileNazwaOrginalna()))); //here get full file name
> from DB
> >
> >                     // 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
> > ($path_to_file)));
> >                     $response->setContent(readfile($path_to_file));
> >                     // $response->setContent(file_get_contents
> > (utf8_decode($file->getPath())));
> >                     // $response->sendContent();
> >                     // Exit without a template
> >                     return sfView::NONE;
> >
>


-- 
Thomas Rabaix
http://rabaix.net

--~--~---------~--~----~------------~-------~--~----~
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