KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm using database query in PHP to retrieve a binary file. But when I'm trying to force download it, the header('Content-type: application/octet-stream') line cause 0 byte files. Without that line I can download the file with full content. It's a binary file that's for sure so I just can't understand why that line causes the problem. The code: $result = mysql_query("SELECT data FROM stored_file WHERE file_name = '$q'"); while($row = mysql_fetch_array($result)) { $file = $row['data']; } header('Content-disposition: attachment; filename='.$q); header('Content-type: application/octet-stream'); header('Content-Length: '.filesize($file)); header("Pragma: no-cache"); header("Expires: 0"); echo $file; Any idea? Thanks.
Tags (comma-separated)
Save Edits
Cancel