views:

231

answers:

1

I am uploading files(any type) in MySql tables's blob field. Now I am able to get binary data from that field and when I print it, it shows binary data in firbug console. But I want to download that file as it was uploaded.

How can I convert this binary data into orignal file? How to do it in zend?

Thanks

+1  A: 

You need to set the headers at minimum you need

<?php
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"".$filename."\";");
echo $data;
exit;
?> 

Or preferablly

<?php
header("Pragma: public");
      header("Expires: 0");
      header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
      header("Cache-Control: private",false);
      header ( "Content-Type: $filedatatype" );
      header("Content-Disposition: attachment; filename=\"".$FileObj->name."\";");
      header("Content-Transfer-Encoding:­ binary");
      header("Content-Length: ".$filesize);
echo $data;
exit;
?> 
MindStalker