No Code Attached Yet
avatar djayko
djayko
25 Aug 2021

Steps to reproduce the issue

  • setup plain joomla4 instance at php 8.0 or 7.3 or 7.4 with mysql 5.7
  • keep standard setup values for uploads
  • set server memory_limit to -1 (=no limit)
  • upload an image via Menu -> Content -> Media

Expected result

  • image uploaded

Actual result

  • error message ""This file is too large to upload."

System information (as much as possible)

  • shared webspace on Ionos with PHP 8.0.9 mysql 5.7.33
  • standard memory set up on serverside is memory_limit=-1 (nolimit)
  • php settings from joomla4-system information
    Upload Max Filesize | 64M
    Post Max Filesize | 64 M
    Memory Limit | -1

Additional comments

  • tested on IONOS - Unlimited Plus - Shared Webhosting (everything is working fine on a joomla 3.10 instance on same webspace)
  • tested with different image file types and sizes (from 1KB to 8MB)
  • after creating a php.ini or .user.ini with "memory_limit="1024M" it worked well - i also tested lower limits like 32MB, 138MB etc.
  • reference discussion: https://forum.joomla.org/viewtopic.php?f=811&t=987786&p=3636942#p3636942
avatar djayko djayko - open - 25 Aug 2021
avatar joomla-cms-bot joomla-cms-bot - change - 25 Aug 2021
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 25 Aug 2021
avatar PhilETaylor
PhilETaylor - comment - 25 Aug 2021

Not a Joomla issue. This is a hosting issue.

If you override your default webhost settings with sensible sane defaults then it will work, as you have found out.

Also note that memory_limit has no bearing on the ability to upload files. This is a memory limit that PHP can consume when running.

delete ALL php.ini and .user.ini files throughout your webspace and use your web hosts (hopefully sane) defaults.

Also you should NEVER need to override and set a PHP Session save path (as I see you mention in your forum post) if you do - then your webhost is pathetic and incorrectly configured.

https://forum.joomla.org/viewtopic.php?f=811&t=987786&p=3636942#p3636586

UPDATE:
By accident i figured out something strange.
I just created an empty php.ini file in joomla-root/administrator and this resulted in diffent values for post_max_size and memory_limit.
-> I tried to upload a file and it worked.
avatar jwaisner jwaisner - change - 27 Aug 2021
Status New Closed
Closed_Date 0000-00-00 00:00:00 2021-08-27 02:42:50
Closed_By jwaisner
avatar joomla-cms-bot joomla-cms-bot - change - 27 Aug 2021
Closed_Date 2021-08-27 02:42:50 2021-08-27 02:42:51
Closed_By jwaisner joomla-cms-bot
avatar joomla-cms-bot joomla-cms-bot - close - 27 Aug 2021
avatar jwaisner
jwaisner - comment - 27 Aug 2021

Thank you @djayko for reporting this. Based on the information provided, this is not a Joomla issue but a hosting issue. Please work with your hosting provider to resolve.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/35360.

avatar joomla-cms-bot
joomla-cms-bot - comment - 27 Aug 2021

Set to "closed" on behalf of @jwaisner by The JTracker Application at issues.joomla.org/joomla-cms/35360

avatar djayko
djayko - comment - 27 Aug 2021

Not a Joomla issue. This is a hosting issue.

I know, but joomla doesn't work as expected with setup of memory_limit = -1

If you override your default webhost settings with sensible sane defaults then it will work, as you have found out.

I found it out, but only accidently. Maybe a recommendation during joomla setup would help if it's not an joomla issue.

Also note that memory_limit has no bearing on the ability to upload files. This is a memory limit that PHP can consume when running.

I know and that's the reason for reporting this issue. It doesn't make sense getting and error message "This file is too large to upload." if memory_limit is set to -1

delete ALL php.ini and .user.ini files throughout your webspace and use your web hosts (hopefully sane) defaults.

I did it already. web host default is memory_limt = - 1
Result: I can't upload images and get error message "This file is too large to upload."

Also you should NEVER need to override and set a PHP Session save path (as I see you mention in your forum post) if you do - then your webhost is pathetic and incorrectly configured.

It was the right way for figuring out what could be wrong or help and also there are
Normally, I don't use that overrides. And joomla 3.10 is working well without any overrides.
But it was helpful figuring some points for reporting.

Summary:
Media Manager is showing error "This file is too large to upload." on standard server setup from my host with memory_limit = -1 (for no limit)
on Joomla 3.10. its working well on same server with same settings.

avatar PhilETaylor
PhilETaylor - comment - 27 Aug 2021

ok let me say this again.

"Also note that memory_limit has no bearing on the ability to upload files. This is a memory limit that PHP can consume when running."

avatar djayko
djayko - comment - 27 Aug 2021

ok let me say this again.

"Also note that memory_limit has no bearing on the ability to upload files. This is a memory limit that PHP can consume when running."

And let me state again, I know that memory_limit is an hoster issue.
But this behaviour and the error emssage as well is not expected and not comprehensible for me as well.
And that's reason why I reported this. Because this behaviour is strange regarding no upload is happening and error message is "This file is too large to upload."
Thats a topic for joomla.

One assumption, the error message is wrong. And why does it occur in the dependency of memory_limit?
Next assumption, memory_limit=-1 is not handled correctly by joomla or maybe it needs at least and infromation towards user to check server configuration (maybe during installation or upgrade), so that the user is able setting up the correct settings with his host.

avatar djayko
djayko - comment - 27 Aug 2021

additional information:
just for your information. memory_limit is an issue withing the code for uploading a file.
As you can see, there is a comparison between filesize and memory_limit and this causing the error due to the fact that server standard is set to "memory_limit=-1"

|| $serverlength > $helper->toBytes(ini_get('memory_limit'))

if 1kb > -1 then error message

file:
root/administrator/components/com_media/src/Controller/ApiController.php

line 360:

private function checkContent()
	{
		$params = ComponentHelper::getParams('com_media');

		$helper       = new MediaHelper;
		$serverlength = $this->input->server->getInt('CONTENT_LENGTH');

		if (($params->get('upload_maxsize', 0) > 0 && $serverlength > ($params->get('upload_maxsize', 0) * 1024 * 1024))
			|| $serverlength > $helper->toBytes(ini_get('upload_max_filesize'))
			|| $serverlength > $helper->toBytes(ini_get('post_max_size'))
			|| $serverlength > $helper->toBytes(ini_get('memory_limit')))
		{
			throw new \Exception(Text::_('COM_MEDIA_ERROR_WARNFILETOOLARGE'), 403);
		}
	}

maybe this helps for a better understanding and finding a solution.

best regards,
Ayko

avatar PhilETaylor
PhilETaylor - comment - 27 Aug 2021

No idea what @laoneo was thinking by adding that, because it makes no sense. At no time is PHP trying to load the full content of the request into PHP Memory and therefore memory_limit, as I have repeatedly said, is nothing to do with PHP file uploads.

I'll PR to remove this check.

avatar PhilETaylor
PhilETaylor - comment - 27 Aug 2021
avatar djayko
djayko - comment - 27 Aug 2021

as I have repeatedly said, is nothing to do with PHP file uploads.

Of course. In general I'm completely with you.

I'll PR to remove this check.

Thanks.

avatar laoneo
laoneo - comment - 27 Aug 2021

@PhilETaylor If you would do a proper check then you would see that this code was added 9 years ago 627e9c4 and not as part of the new media manager. If you fix it in 4 then you probably want to fix it also in 3.

avatar josephsimony
josephsimony - comment - 18 Dec 2021

Same - This file is too large to upload - issue confirmed on all of our servers.

The uploads work well with the latest J! 3.x; doesn't work on 4.x. on the exact same environments. No matter if PHP 7.4.x or 8.x is used.

Not with memory_limit modifications nor php.ini/user.ini deletion or .htaccess modification, or anything else we tried.

The only solution was to modify the lines within administrator/components/com_media/src/ControllerApiController.php

Thanks again @djayko .

@PhilETaylor - no comment.

Happy to send any debug or other information if requested.

avatar PhilETaylor
PhilETaylor - comment - 18 Dec 2021

The only solution was to modify the lines within administrator/components/com_media/src/ControllerApiController.php

What exactly did you modify ?

Add a Comment

Login with GitHub to post a comment