Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/app_local.example.php
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,7 @@
// ],
// ],
// 'uploadMaxResolution' => '1920x1080',
// 'uploadMaxSize' => -1, // -1 means no limit, otherwise set a limit in bytes

/**
* Configuration for "Children" association parameters.
Expand Down
5 changes: 4 additions & 1 deletion resources/js/app/helpers/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,11 @@ export default {
* @returns {Boolean}
*/
checkMaxFileSize(file) {
const fileSize = Math.round(file.size);
const maxFileSize = BEDITA.maxFileSize;
if (maxFileSize < 0) {// no limit
return true;
}
const fileSize = Math.round(file.size);
if (fileSize >= maxFileSize) {
const filename = file.name;
const fileSizeMb = Math.round(fileSize / 1024 / 1024);
Expand Down
4 changes: 4 additions & 0 deletions src/View/Helper/SystemHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ class SystemHelper extends Helper
*/
public function getMaxFileSize(): int
{
$forcedMaxFileSize = Configure::read('Upload.uploadMaxSize');
if ($forcedMaxFileSize) {
return $forcedMaxFileSize;
}
$postMaxSize = intVal(substr(ini_get('post_max_size'), 0, -1));
$uploadMaxFilesize = intVal(substr(ini_get('upload_max_filesize'), 0, -1));

Expand Down
6 changes: 6 additions & 0 deletions tests/TestCase/View/Helper/SystemHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ public function testGetMaxFileSize(): void
$expected = min($pms, $umf) * 1024 * 1024;
$actual = $this->System->getMaxFileSize();
static::assertSame($expected, $actual);
// test with forced max file size
$forcedMaxFileSize = -1;
Configure::write('Upload.uploadMaxSize', $forcedMaxFileSize);
$actual = $this->System->getMaxFileSize();
static::assertSame($forcedMaxFileSize, $actual);
Configure::delete('Upload.uploadMaxSize');
}

/**
Expand Down
Loading