mirror of
https://github.com/prasathmani/tinyfilemanager.git
synced 2025-08-01 22:40:58 +02:00
Downloading file - PHP warning loop "Permission denied" (#879)
* Bugfix: Stop looping error when downloading a file with no access. * Delete .history directory ignore .history
This commit is contained in:
@@ -3060,6 +3060,26 @@ function fm_download_file($fileLocation, $fileName, $chunkSize = 1024)
|
|||||||
$contentType = implode(' ', $contentType);
|
$contentType = implode(' ', $contentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$size = filesize($fileLocation);
|
||||||
|
|
||||||
|
if ($size == 0) {
|
||||||
|
fm_set_msg(lng('Zero byte file! Aborting download'), 'error');
|
||||||
|
fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
|
||||||
|
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ini_set('magic_quotes_runtime', 0);
|
||||||
|
$fp = fopen("$fileLocation", "rb");
|
||||||
|
|
||||||
|
if ($fp === false) {
|
||||||
|
fm_set_msg(lng('Cannot open file! Aborting download'), 'error');
|
||||||
|
fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
|
||||||
|
|
||||||
|
return (false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
header("Cache-Control: public");
|
header("Cache-Control: public");
|
||||||
header("Content-Transfer-Encoding: binary\n");
|
header("Content-Transfer-Encoding: binary\n");
|
||||||
header("Content-Type: $contentType");
|
header("Content-Type: $contentType");
|
||||||
@@ -3076,7 +3096,6 @@ function fm_download_file($fileLocation, $fileName, $chunkSize = 1024)
|
|||||||
|
|
||||||
header("Accept-Ranges: bytes");
|
header("Accept-Ranges: bytes");
|
||||||
$range = 0;
|
$range = 0;
|
||||||
$size = filesize($fileLocation);
|
|
||||||
|
|
||||||
if (isset($_SERVER['HTTP_RANGE'])) {
|
if (isset($_SERVER['HTTP_RANGE'])) {
|
||||||
list($a, $range) = explode("=", $_SERVER['HTTP_RANGE']);
|
list($a, $range) = explode("=", $_SERVER['HTTP_RANGE']);
|
||||||
@@ -3092,12 +3111,6 @@ function fm_download_file($fileLocation, $fileName, $chunkSize = 1024)
|
|||||||
header("Content-Length: " . $size);
|
header("Content-Length: " . $size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($size == 0) {
|
|
||||||
die('Zero byte file! Aborting download');
|
|
||||||
}
|
|
||||||
@ini_set('magic_quotes_runtime', 0);
|
|
||||||
$fp = fopen("$fileLocation", "rb");
|
|
||||||
|
|
||||||
fseek($fp, $range);
|
fseek($fp, $range);
|
||||||
|
|
||||||
while (!feof($fp) and (connection_status() == 0)) {
|
while (!feof($fp) and (connection_status() == 0)) {
|
||||||
|
Reference in New Issue
Block a user