I'm not very good with php coding, however reading through and old post on PDF corrupt on download and performing a few trial & error.
I commented out the if statements in the HTTP RANGE coding in phocadownload.php in the helper folder.
Downloaded again all my files and all are working ok now. I really don't understand the coding and logic behind all this or if there are any future problems by commenting out the if statements. For now I am just happy the downloads are working.
// Modified by Rene
// HTTP Range - see RFC2616 for more informations (
http://www.ietf.org/rfc/rfc2616.txt)
$httpRange = 0;
$newFileSize = $fileSize - 1;
// Default values! Will be overridden if a valid range header field was detected!
$resultLenght = (string)$fileSize;
$resultRange = "0-".$newFileSize;
// We support requests for a single range only.
// So we check if we have a range field. If yes ensure that it is a valid one.
// If it is not valid we ignore it and sending the whole file.
if(isset($_SERVER['HTTP_RANGE']) && preg_match('%^bytes=\d*\-\d*$%', $_SERVER['HTTP_RANGE'])) {
// Let's take the right side
list($a, $httpRange) = explode('=', $_SERVER['HTTP_RANGE']);
// and get the two values (as strings!)
$httpRange = explode('-', $httpRange);
// Check if we have values! If not we have nothing to do!
/*if(!empty($httpRange[0]) || !empty($httpRange[1])) {
// We need the new content length ...
$resultLenght = $fileSize - $httpRange[0] - $httpRange[1];
// ... and we can add the 206 Status.
header("HTTP/1.1 206 Partial Content");
// Now we need the content-range, so we have to build it depending on the given range!
// ex.: -500 -> the last 500 bytes
if(empty($httpRange[0]))
$resultRange = $resultLenght.'-'.$newFileSize;
// ex.: 500- -> from 500 bytes to filesize
elseif(empty($httpRange[1]))
$resultRange = $httpRange[0].'-'.$newFileSize;
// ex.: 500-1000 -> from 500 to 1000 bytes
else
$resultRange = $httpRange[0] . '-' . $httpRange[1];
//header("Content-Range: bytes ".$httpRange . $newFileSize .'/'. $fileSize);
} */
}
header("Content-Length: ". $resultLenght);
header("Content-Range: bytes " . $resultRange . '/' . $fileSize);
header("Content-Type: " . (string)$mimeType);
header('Content-Disposition: attachment; filename="'.$fileWithoutPath.'"');
header("Content-Transfer-Encoding: binary\n");