Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP Download Not Working in Google Chrome
Old 11-30-2009, 10:57 AM PHP Download Not Working in Google Chrome
Galaxian's Avatar
Rich Powell

Posts: 842
Name: Rich Powell
Location: United Kingdom
Trades: 0
This code doesn't seem to work in Chrome, can anyone identify the problem?

PHP Code:
         if(is_file($fileaddy)) { 
        
            
//show the appropriate header, or set a download file header
            
             
@ob_end_clean(); //turn off output buffering to decrease cpu usage
             
             // required for IE, otherwise Content-Disposition may be ignored
             
if(ini_get('zlib.output_compression'))
              
ini_set('zlib.output_compression''Off');
              
/* The three lines below basically make the 
                download non-cacheable */
             
header("Cache-control: private");
             
header('Pragma: private');
             
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
             
header("Content-Disposition: attachment; filename=\"" basename($fileaddy))."\"";
            
header("Content-Type: application/force-download");
            
header("Content-Type: application/octet-stream");
            
header("Content-Type: application/download");
            
header("Content-Type: ".filetype($fileaddy)); 
             
header("Content-Description: File Transfer");
            
header("Content-Length: " filesize($fileaddy));
            
header("Content-Transfer-Encoding: binary");
            
header('Accept-Ranges: bytes');
            
            
$fp fopen($fileaddy"r");
            while (!
feof($fp))
             {
                echo 
fread($fp65536);
                
flush(); // this is essential for large downloads
            

            
fclose($fp); 
        }
    
    }


__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Please help get the new
Please login or register to view this content. Registration is FREE
forum started for Webmasters like you!

Galaxian is offline
Reply With Quote
View Public Profile Visit Galaxian's homepage!
 
 
Register now for full access!
Old 12-02-2009, 07:02 AM Re: PHP Download Not Working in Google Chrome
lazcorp's Avatar
Average Talker

Posts: 22
Name: Martin
Trades: 0
You have sintax error on this line and that is the reason:
header("Content-Disposition: attachment; filename=\"" . basename($fileaddy))."\"";

It must be (see the closing bracket):
header("Content-Disposition: attachment; filename=\"" . basename($fileaddy)."\"");


You can not to send more than one kind of header. So from this all:

header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Type: ".filetype($fileaddy));


... the browser will receive only the last one send:

header("Content-Type: ".filetype($fileaddy));


If you use Firefox, then use some kind of Headers sniffer to see what the browser receivs.
lazcorp is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to PHP Download Not Working in Google Chrome
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.53854 seconds with 12 queries