Current location: Hot Scripts Forums » Programming Languages » PHP » php force download problem


php force download problem

Reply
  #1 (permalink)  
Old 01-05-06, 09:50 PM
mitchlrm mitchlrm is offline
New Member
 
Join Date: May 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
php force download problem

I'm trying to force the download of a wmv file. Using the following
PHP Code:

if(ini_get('zlib.output_compression'))

 
ini_set('zlib.output_compression''Off');
            
$size filesize(videodir.$filename);
      
//      echo("size ".$size);
            
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: application/force-download");
            
header("Content-Disposition: attachment; filename=\"".$filename."\";");
            
header("Content-Transfer-Encoding: binary");
            
header("Content-Length: ".$size);readfile(videodir.$filename); 
It does actually download the file but it adds about 5 bytes to the beginning of the file that makes it unusable.

Any advice on how to avoid the extra bytes???
Reply With Quote
  #2 (permalink)  
Old 01-06-06, 03:32 AM
djdykes djdykes is offline
Newbie Coder
 
Join Date: Dec 2005
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
try using file get contents as readfile is used for outputting stuff directly to a browser.... i am unaware that this should make a difference but try

PHP Code:

header("Content-Length: ".$size);file_get_contents(videodir.$filename); 

__________________
*****************************************
Learn PHP at PHP for Beginners or perhaps a little Poker?
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Force Download Problem Nathor PHP 8 08-10-05 11:07 PM
PHP Download System - Free Woolf Script Requests 0 06-25-05 05:19 PM
PHP multi-dimensional array sorting issue aqw PHP 2 06-24-05 11:09 PM
Need some help with php download system renatik Script Requests 0 01-06-05 12:59 PM
PHP download... niceguyonline Script Requests 3 03-06-04 05:41 PM


All times are GMT -5. The time now is 06:27 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.