views:

70

answers:

1

I am storing files into an image field in SQL server storing the string in hex after converting into using:

unpack("H*hex", $datastring);

If I read from the database and write to a file, then open the file locally I can open it up just fine. But if I try to send the file as an attachment to the browser the file becomes corrupted and unreadable. Currently, the files in question are PDF and MSWord documents.

I am setting content-type to the appropriate MIME type for the files and setting content-disposition to attachment. I've tried various ways of streaming the file including dumping the string directly from the database and writing first to a file then reading the file (either line by line or with readfile()).

I am using a slightly customized version of the Zend framework, but I'm not sure if that is causing any issues. What should I do to send files to the browser?

A: 

How do you serve them?, in theory if you are using MVC, you need to disable the view at the end of your controller to avoid extra content being inyected at the bottom of your file.

Chris
The layout is being changed to one that only shows view content and nothing else.
illvm
Try to serve the content without Zend_View directly from the MVC and then perform a exit; at the end to avoid the dispatcher to continue and posibly inyecting content.
Chris