This is my first topic here, and I'm going to introduce myself really quick.
My name is Fredrik Duwell (obviously) and I come from the southern part of Sweden. I'm a PHP-programmer, mostly dedicated on my sparetime etc.
Today I've got a problem with one of my new projects. It's a service we were supposed to publish a few days ago, but we're delayed just because of this small issue. I bet it is kind of easy to solve, but I'm out of ideas.
Here we go!
When a file is being uploaded, there's no problem. There's however an issue when the file is being downloaded because Apache freezes until the file is completely downloaded, and when I say "freezes" I really mean for everyone. None can access the website until download is completed.
I'm using a method that reads the file in some way, sends it in pieces etc. Here, have a look at the source;
$file['location'] = @fopen($config['filetransfer']['directory'].'/'.$download['data']['fetch']['id_unique'].'.'.$download['data']['fetch']['filename_extension']);
$file['filesize'] = @filesize($config['filetransfer']['directory'].'/'.$download['data']['fetch']['id_unique'].'.'.$download['data']['fetch']['filename_extension']);
if($file['location']) {
// Create the headers used for downloading the file
header("Content-Transfer-Encoding: binary");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Accept-Ranges: bytes");
header("Content-Disposition: attachment; filename='{$config['filetransfer']['prefix']}{$download['data']['fetch']['filename']}");
header("Content-Length: {$file['filesize']}");
// Actually start downloading the file
while (!feof($file['location'])) {
echo(@fgets($file['location'], 4096));
}
/**
* Update the total of
* downloaded in user's account.
*/
/* Removed, hehe */
/**
* Close the stream
*/
fclose($file['location']);
}
I've also searched for every solution, tried a few but nothing seems to work. I don't feel very lucky right now!
I'd be more than happy if someone took the initiative and helped me to solve this.
Thank you.

New Topic/Question
Reply




MultiQuote







|