one.com and mybb | File Attachment Undefined Fatal Error | Format of memory_limit

MyBB Attachment Fatal Error Fix one.com

As a new forum owner, I was excited to use the cheap domain and hosting site one.com with mybb 1.8.10. I was dissapointed when I kept getting this error whenever I tried to upload some png and jpeg/jpg files:

How to fix undefined attachment error mybb 1.8.10
How to fix undefined attachment error mybb 1.8.10

Or, when I wasn’t using my Multiple File Uploader and used mybb’s normal file attachment uplader, I got a white screen and it said this:

Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 12288 bytes) in /customers/a/4/e/ontic-philosophy.com/httpd.www/inc/functions_image.php on line 52

The problem is down to how one.com expresses the max_post_size in php info:

Got to ACP>Tools and Maintainence>View PHP Info

Scroll down or CTRL+F memory_limit and post_max_size:

max_post_size one.com php info mybb fix
max_post_size one.com php info mybb fix
memory limit one.com php info mybb fix
memory limit one.com php info mybb fix

As you can see, the format of the memory limit is 536870912 when it should be in the format of 128MB (that’s not the equivalent here I don’t think, but the point is how it is show in this PHP info section that is the problem.)

You don’t have to call one.com and ask them to change the way this variable is laid out, which you probably have done already and they told you ‘no’.

Don’t worry, there is a fix.

If the post_max_size is less than the size of files you want to upload and you have not altered the attachment sizes in your ACP>Configuration section, then either the file you are uploading is too big, or youhave not set the sizes in the ACP.  If you have changed them and the file you want to upload is smaller than 96MB (or whatever your post_max_size is) then here is the way to fix this problem.

The fix

Note: I was having problems with uploading png and jpeg/jpg files, if you have problems with files of a different type, find the same lines that correspond to the file extentions in the functions_image.php file and use the same methods you see below.

 

Open your FTP and download root/inc/functions_image.php and then open it using notepad.

Got to lines 52 and 59, which looks like this:

 if(@function_exists("imagecreatefrompng"))
{
$im = @imagecreatefrompng($file);
}
}
elseif($imgtype == 2)
{
if(@function_exists("imagecreatefromjpeg"))
{
$im = @imagecreatefromjpeg($file);
}
}
elseif($imgtype == 1) 

Remove all the @ symbols.

This will stop the screen from just whiting out, instead it will show the fatal error text. if it looks the same as mine above, then do this:

Open the functions_image.php file again and change line 167-169:

function check_thumbnail_memory($width, $height, $type, $bitdepth, $channels)
{
if(!function_exists("memory_get_usage")) 

To this:

function check_thumbnail_memory($width, $height, $type, $bitdepth, $channels)
{
 return false;
if(!function_exists("memory_get_usage")) 

Now try to upload your file(s).

This worked for me, mybb is currently discussing whether or not this should be changed in the next version, A few people have left one.com because of this problem, so I thought I would share the fix.

 

 

Share this content: