The only problem will be that if you do not sent the appropriate content type headers, then the browser will not know what to do with the big chunk of binary data you spit out - is this an image, a word document, a html page? Should it try to save this data, or display it inline?
http://au3.php.net/manual/en/function.header.php#48538 has an example that should work for you. It would be a good idea to also have a Configure::write('debug', 0); before it (you don't want any cake SQL logs messing up the file), and it wouldn't hurt to have @flush(); @ob_end_flush(); exit(); right at the end (make sure all buffered data is fully sent before the exit). On Oct 15, 10:46 am, Langdon Stevenson <[EMAIL PROTECTED]> wrote: > I have a set of files stored in a protected directory on my project's > server. I need my Cake app to send files to users, however due to > security reasons, I can't just use a redirect that points the web > browser to the appropriate file. > > My code takes a parameter from the submitted URL, checks if the user is > allowed to access the file and if successful sends the file to the user. > > It is the last part of this that I can't figure out. > > Can anyone point me to example PHP code or something Cake specific for > reading a file from disk and returning it to the user without parsing > the file? > > I have spent some time searching and trying things with no luck so far. > > For instance, using get_file_contents() in an empty view results in > corrupt files being returned to the browser. > > Any suggestions greatly appreciated. > > Regards, > Langdon --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
