Skip to content

fix(templates): use PHP upload limit for global template size - #6248

Open
s0undy wants to merge 1 commit into
nextcloud:mainfrom
s0undy:fix/template-upload-size-from-php-limits
Open

s0undy wants to merge 1 commit into
nextcloud:mainfrom
s0undy:fix/template-upload-size-from-php-limits

Conversation

@s0undy

@s0undy s0undy commented Oct 28, 2026

Copy link
Copy Markdown

Fixes #6175

Summary

Replaces the hardcoded 20 MB template limit with the smaller of upload_max_filesize and post_max_size. The "File is too big" error now includes that limit, e.g. "File is too big. The maximum upload size is 10 MB". Requests over post_max_size, which PHP drops entirely, now show the same error instead of "Invalid file provided".

Checklist

  • Code is properly formatted
  • Sign-off message is added to all commits
  • Documentation (manuals or wiki) has been updated or is not required

Replace the hardcoded 20 MB limit with OCP\Util::uploadLimit(), the
smaller of upload_max_filesize and post_max_size, and include the
limit in the "File is too big" error. Requests over post_max_size,
which PHP drops entirely, now get the same error instead of
"Invalid file provided".

Fixes nextcloud#6175

Assisted-By: Claude Opus 5.5

Signed-off-by: Anton Josefsson <antonjosefsson@hotmail.se>
@s0undy
s0undy force-pushed the fix/template-upload-size-from-php-limits branch from 976e4f0 to 908b6ec Compare October 28, 2026 21:26
@s0undy

s0undy commented Nov 2, 2026

Copy link
Copy Markdown
Author

Think you can have a quick look? @juliusknorr


if (is_uploaded_file($files['tmp_name']) && !Filesystem::isFileBlacklisted($files['tmp_name'])) {
if ($files['size'] > $this->maxSize) {
if ($files['size'] > Util::uploadLimit()) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it already be rejected here by PHP, making this check redundant?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make the maximum global template upload size configurable instead of hardcoded

2 participants