grejon04 Posted August 8, 2007 Share Posted August 8, 2007 I've revised a test piece of code to narrow out some other variables. This downloads a .doc file that is filled with gibberish, the text somewhere in the middle of it. Word asks me which encoding method I'm using. I tried turning SSL off and that did nothing. MacOSX Apache server, php 5.2. something. Any ideas on what could be messing up my file? I know they're ok on the server. <?php require_once 'includes/securitycheck.inc'; require_once 'includes/dbconnect.inc'; require_once "includes/manuscript_functions.inc"; require_once "includes/functions.inc"; $title = "testdocument"; //header('Vary: User-Agent'); Do I need this? Does Apace add a header of some sort? header('Content-Description: File Transfer'); header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header('Content-Type: application/msword');//I tried force-download here, and it did nothing header("Content-Transfer-Encoding: binary"); header('Content-Length: ' . filesize("/u/staff/jrme/jrme_files/manuscripts/07322o.doc")); header("Content-Disposition: attachment; filename=" . $title . ".doc");//maybe a different disposition? readfile("/u/staff/jrme/jrme_files/manuscripts/07322o.doc"); exit(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/63897-downloading-problems/ Share on other sites More sharing options...
lemmin Posted August 8, 2007 Share Posted August 8, 2007 I would try using fopen, fread, and fwrite. The documentation on php.net doesn't state whether or not readfile() is binary safe or not. I know that you can use fopen in a binary safe mode by including "b" in your mode string. Quote Link to comment https://forums.phpfreaks.com/topic/63897-downloading-problems/#findComment-318614 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.