Hi,

I assume that you mean you want to send the file as
application/octet-stream. Take a look at this:


ob_start();

$path = 'path to directory where file resides';
$filename = 'the name of the file';

ob_end_clean();

header("Pragma: public");
header("Expires: 0"); // set expiration time
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=$filename");
header("Content-Transfer-Encoding: binary");
$filesize = filesize($path.$filelocation);
header("Content-Length: $filesize");    

echo file_get_contents($path.$filelocation);



You could also use fread() or similar if the file is larger.

Let me know if it helped.

Best regards,
Peter Lauri

www.dwsasia.com  - company web site
www.lauri.se  - personal web site
www.carbonfree.org.uk  - become Carbon Free


-----Original Message-----
From: Mike Mannakee [mailto:[EMAIL PROTECTED] 
Sent: Saturday, September 16, 2006 2:39 AM
To: php-general@lists.php.net
Subject: [PHP] Pushing a file to the browser

Hello,

I have a script I've created which takes a file upload, monkeys with the 
data in it, and needs to push the new file out to the browser.  Everything 
is coded and working up to that last point, but I've never pushed out a file

to the browser before.  Does anyone have the code for this laying around 
that I can see (and modify)?

Mike 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to