Jump to content

[SOLVED] File Download Issue


Syphon

Recommended Posts

I've got a simple file download script that runs great on my localhost. When I'm testing on our live server it takes forever (1-2 min or so) for the FireFox save dialogue to pop up. When it eventually does and I download the file, the size is 0KB and the file is completely blank! Any ideas on what's causing this? The actual size of the file I'm downloading is less than 5KB.

Link to comment
https://forums.phpfreaks.com/topic/133679-solved-file-download-issue/
Share on other sites


// This script is within a class. The variables values are below
// $this->FileLocation = /var/www/html/files/testfile.txt
// $this->FileMIME = application/octet-stream
// $this->FileName = "My File"
// $this->FileSize = 1233

$FileLocation = APPROOT."files/".$this->FileLocation;
$FileExt = strrchr($this->FileLocation, ".");
header("Content-Type: ".$this->FileMIME);
header("Content-Transfer-Encoding: Binary");
header("Content-Length: ".$this->FileSize);
header("Content-Disposition: attachment; filename=\"".basename(str_replace(" ", "", $this->FileName).$FileExt)."\"");
readfile($FileLocation);
exit;

Hmm, the problem seems to have fixed itself. On our live testing servers I can't seem to download the file; however if the code is executed on the live site (just a different directory on the same server) it works as expected. I wonder if SSL is some how to blame. If it works on my live site then I'm not concerned anymore. It'd be nice to figure out why it doesn't work in a different directory on the same server though.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.