Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with error reporting in media manager - Joomla 4.4 #43387

Open
paulkosciecha opened this issue Apr 27, 2024 · 3 comments
Open

Problem with error reporting in media manager - Joomla 4.4 #43387

paulkosciecha opened this issue Apr 27, 2024 · 3 comments

Comments

@paulkosciecha
Copy link

Steps to reproduce the issue

  • Set filesize limit in 4mb in Mediamanager settings
  • Upload file under 1mb - uploads fine
  • Upload file of 3.5mb - get error message that file is too large
  • Upload file of 8mb+ - get message saying file uploaded, blue line progresses, but no file appears

Expected result

Error reporting should be consistent with the scenario. It should not say the file is too large when it isn't bigger than the limits set in mediamanager - if these are lower than php. It should throw the error when the file is too big and not say it is uploaded.

Actual result

File is too big Error throws in scenerio where file is below the threshold. File uploaded message where the file is too big.

System information (as much as possible)

  • Joomla 4.4.0
  • Mamp server run locally as dev
  • php.ini - post_max_size = 8M, upload_max_filesize = 32M
  • Safari browser

Additional comments

@richard67
Copy link
Member

richard67 commented Apr 28, 2024

The 3.5 issue could be the result of rounding a float to an integer in combination with wrong logic so >= is used instead of > (which would be wrong of course, am just thinking about what could cause that).

@brianteeman
Copy link
Contributor

Confirmed using Joomla 5.1

  • media manager set to 4mb

  • php Upload Max Filesize 100M

  • php Post Max Size 100M

Test 1 (filesmall.jpg 467kb) ✔️

image

Test 2 (filemed.jpg 3,792kb) ❌

image

Test 3 (filelarge.jpg 4,500kb) ✔️

image

@Quy Quy added the bug label Apr 28, 2024
@mabdelaziz77
Copy link

I'm debugging this issue and found that the Upload function of the Media Manager is using the File: readAsDataURL() method where the file's data is represented as a base64 encoded string.

That means the size of the Base64 version of the file is typically roughly a third larger than its source, refer to Encoded size increase
For example if the file size is 3.5mb (3670016 bytes), the size of its Base64 version will be ~4881121 bytes.
In our case the filesize limit is set to 4mb (4194304 bytes), it is clear enough that the size of the Base64 version is larger than the filesize limit, so the upload is failed and says the file is to large to upload!

I tried multiplying filesize limit by 1.33 before checking the file size and it works:
$paramsUploadMaxsize = $params->get('upload_maxsize', 0) * 1024 * 1024 * 1.33;

but I'm not sure whether this is the best approach to handle it, please let me know your thoughts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants