Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Large file download in 5.2.3?

Status
Not open for further replies.

dle46163

IS-IT--Management
Jul 9, 2004
81
US
Hi All,

I have a script for allowing web users to download files from my web site. It worked great with PHP version 5.0.4.. I had some problems with that version so upgraded to 5.2.3 - Some things seemed improved. However, now when I use this script I can't download large files. PHP just sits there and spins its wheels... Is there a setting somewhere that I need to adjust? I'm using PHP 5.2.3, IIS6, Win2003 Server. Here's my code:

$mm_type="application/octet-stream"; // Set mime type
$url="../pics/dc.jpg"; // Set directory path

if(file_exists($url)){
header("Cache-Control: public, must-revalidate");
header("Pragma: hack");
header("Content-Type: " . $mm_type);
header("Content-Length: " .(string)(filesize($url)) );
header('Content-Disposition: attachment;
filename="'.basename($url).'"');
header("Content-Transfer-Encoding: binary\n");


$fp = fopen($url, 'rb'); // Open file
$buffer = fread($fp, filesize($url)); // Buffer
fclose ($fp); // Close file

print $buffer; // Print the buffer
}

if(!file_exists($url)){
echo "Incorrect file name or file did not exist!";
}
 
try readfile instead of fopen+fread.

but unlikely to be the actual problem. compare the php.ini files of the two servers. probably a config difference.
 
Due to some specific settings,I used the original php.ini for the second install.. Might this be causing a problem? Meantime, I'll try readfile....
 
i might well cause problems, for example if you have moved OS's or webservers or if the file system directives do not map to an existing directory with the correct permissions.

i cannot think of anything like the above that would directly effect downloads though.
 
The new install is on the same server... I finally gave up and went back to 5.0.4.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top