Uploading files in manager not working anymore


Somehow the file upload function got broken on our MODx install. It used to work fine, but last week I got a report that an editor could not upload anymore.

When uploading something with the uploader window it shows a message like this (translated from Dutch) “The filesize (183.3KiB) is bigger than NaN KiB”. Different files give different number, but the NaN KiB is always there.

I did increase the "upload_maxsize"setting in MODx recently to 25MB, but it is still lower than the PHP “upload_max_filesize” which is set to 32M.

I don 't know how to debug this further at this point.

Step to reproduce

Try to upload a file through the Files tab in the manager.

Observed behavior

As described above

Expected behavior

Allow to upload files like before.


MODX version tagged when creating the issue, Apache or NGINX with version, MySQL version, browser, etc. Any relevant information.

MODX Revolution 2.7.3-pl (traditional)
Apache, not sure about the version that is handled by the hoster.
SQL: 10.1.44-MariaDB-cll-lve
PHP Version 7.3.16


Have a look on php settings related with post Max size and upload Max size

I’m not sure what causes this, but it looks like your upload limit contains some invalid characters as you’re getting a “Not a Number” (NaN) as response in there? What’s exactly in your upload_maxsize system setting?

@jnogueira for the php settings I only see " upload_max_filesize" which is set to 32M. The other max_size I could find was “post_max_size” which is also 32M.

@vibedesign the value just reads like a number. In this case 25000000. I input a value by clicking the number, type the new number and press Enter.

Try your .htaccess file or php.ini.

[1] .Htaccess
[2] php.ini

Another tip:
I faced this same issue on the past related with Apache modSecurity. After disabling it, this problem went away.

Thanks for the tips.

Unfortunately I don’t have direct access to the php.ini and also not the main .htaccess file as the site is managed by a DirectAdmin control panel. I have a .htaccess file, but that only contains the MODx stuff.

However when I run phpinfo() it says both “upload_max_filesize” and “post_max_size” are set to 32M. Also note that uploading small files (< 1kB) also fails.

I am not sure if apache is configured with modSecurity, I could not find anything about this in the docs of the hosting company.

I did some more experimentation and I used this basic php upload script (https://gist.github.com/taterbase/2688850) on that same domain and uploading files with that script works fine until I hit the 32MB limit (as expected).

So it seems the issue not generic php, so most likely MODx specific.

It seems the manager gets some bad value for the max_upload setting (hence the NaN error), but I am not sure how that info gets into the manager UI. I tried tracing the traffic with the Chrome devtools, but not sure what I am looking for.

Different sites can load different versions of PHP on the same server so check the phpinfo() inside Manage ->Reports -> System Info in the manager just to be sure you’re looking at the right one.

The crux of the issue will be finding out why your limit is coming through as NaN.

I checked phpinfo inside the MODx manager and in the temporary upload script and both give the same info PHP Version is 7.3.16 (can post more info if relevant, just not sure what).

The tracing where the NaN is coming from seems to be the only pointer, but that is where I get lost. I just don’t know where to start with that.

Strange. Not sure if it’s relevant then but you do have access to the .htaccess. Try to add

php_value upload_max_filesize 32M
php_value post_max_size 32M

Also, try to update your modx installation. If you’re on the current available version, just use that and follow normal update steps.

I was finally able to track it down.

It turns out that somehow I ended up with some kind of invisible “character” in front of the number I put into the systemsetting for upload size. No idea how it got there. It did not take space, but it was indeed noticeable when I moved the cursor around manually. I then had to press the arrow 2 times.

I found out when I was pasting the number from the browser to a commandline window that apparently did not know that character and printed a box and from there forward things became more clear.

So long story short, it is fixed.

Glad you got sorted!

I thought you checked that, when I mentioned that earlier, haha :smiley: Always the sneaky little things… Glad you found it!

When inputting new numbers I deleted the old ones with backspace until there were no more visible characters. So one more backspace would have fixed it earlier.

1 Like