SMF 2.0.17 - Can only add 20 attachments at a time

Started by GL700Wing, August 16, 2020, 08:21:28 AM

Previous topic - Next topic

GL700Wing

I've done some testing on an SMF 2.0.17 forum with no mods installed and discovered that if the value for the maximum number of attachments allowed per post is set to '0' (ie, unlimited) or to a number greater than '20' only 20 attachments are actually attached to a new/modified post at a time when it is previewed/saved.  However, I also discovered that it is actually possible to attach more than 20 files to a new/modified post by previewing the new/modified post after the first 20 files have been attached and then attaching more files in groups of 20 up to the maximum number of attachments allowed.  There are no error messages displayed or logged ...

Also, and as per the code in ./Sources/Post.php, only 50 attachments per post are allowed when the value is set to '0' (ie, unlimited) so it's not actually unlimited.
./Sources/Post.php
$context['num_allowed_attachments'] = empty($modSettings['attachmentNumPerPostLimit']) ? 50 : min($modSettings['attachmentNumPerPostLimit'] - count($context['current_attachments']) + (isset($deleted_attachments) ? $deleted_attachments : 0), $modSettings['attachmentNumPerPostLimit']);
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

vbgamer45

In PHP there is a setting called  max_file_uploads  which defaults to 20
The maximum number of files allowed to be uploaded simultaneously. Starting with PHP 5.3.4, upload fields left blank on submission do not count towards this limit.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

GL700Wing

Quote from: vbgamer45 on August 16, 2020, 09:06:27 AM
In PHP there is a setting called  max_file_uploads  which defaults to 20
The maximum number of files allowed to be uploaded simultaneously. Starting with PHP 5.3.4, upload fields left blank on submission do not count towards this limit.
Thanks so much for your quick response - I was able to increase the value via cPanel (although I could have added an entry to the php.ini file) and I can now attach more than 20 files at a time.
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

vbgamer45

Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Arantor

I believe this is different in 2.1 where it uses AJAX to upload so it's not subject to the same limit.

Advertisement: