Skip to content

Commit 1230186

Browse files
committed
Fixed allowed memory size exhausted error
1 parent c60ceb1 commit 1230186

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

resources/views/panel/backups.blade.php

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,29 @@
22

33
@section('content')
44
@if (file_exists(base_path('backups/updater-backups/')) and is_dir(base_path('backups/updater-backups/')))
5-
<?php
6-
$filename = $_SERVER['QUERY_STRING'];
7-
8-
$filepath = base_path('backups/updater-backups/') . $filename;
9-
10-
$strFile = file_get_contents($filepath);
11-
12-
header("Content-type: application/force-download");
13-
header('Content-Disposition: attachment; filename="'.$filename.'"');
14-
15-
header('Content-Length: ' . filesize($filepath));
16-
echo $strFile;
17-
while (ob_get_level()) {
18-
ob_end_clean();
5+
<?php
6+
$filename = $_SERVER['QUERY_STRING'];
7+
$filepath = base_path('backups/updater-backups/') . $filename;
8+
9+
if (file_exists($filepath)) {
10+
header("Content-type: application/octet-stream");
11+
header('Content-Disposition: attachment; filename="' . $filename . '"');
12+
header('Content-Length: ' . filesize($filepath));
13+
14+
$file = fopen($filepath, 'rb');
15+
if ($file) {
16+
while (!feof($file)) {
17+
echo fread($file, 8192);
18+
ob_flush();
19+
flush();
20+
}
21+
fclose($file);
1922
}
20-
readfile($filepath);
21-
exit;
22-
?>
23+
exit;
24+
} else {
25+
echo 'File not found.';
26+
}
27+
?>
2328
@endif
2429

2530
@endsection

0 commit comments

Comments
 (0)