Posted on: 2007/6/2 16:11
Re: Newbb Uploads Failing
OK, I have the upload of large files working.
For anyone that is interested, here's what you have to do:
First - and I'm not sure this was really a problem, but it's always a good idea - I upgraded to the latest stable release of CBB (as of this post, 3.08). This was not as easy as I had hoped. I have a cloned template set and for some reason the clone was broken after the upgrade, so it looked like all my forums were gone when I went to the forum page. I recall seeing something a long time ago on that topic and how to fix it, but I only have a couple of minor template changes so it was easier just to create a new clone and duplicate the changes.
Even after that, there was a CBB block missing on the main page. I had to de-activate and reactivate the block in Admin and it came back.
Next, each forum has a setting called "Max Size in kb`s". You will need to bump the size of that up to whatever you think is a reasonable limit. Be aware: this setting is stored in a table called xoops_bb_forums in a column called attach_maxkb. That column is defined as an unsigned smallint (a new change with v3.08). This means you have a limit on the value that field holds of 65535, which means you have a CBB imposed limit of just under 64 Meg. If for some insane reason that is not big enough for you, then you will have to alter the data type for that table to something large enough to suit your evil purposes.
You set the "Max Size in kb`s" at the individual Forum level, so you will find it by editing a Forum in the Admin. While you are in there, you should make sure that the allowed file extensions are suitable to your needs and adjust them if not. A '*' in this setting will remove all file extension restrictions.
I did all that, and I still couldn't get anything larger than 2M to upload; it would *LOOK* like it was uploading, but when the page finally refreshed, there was no attachment. And here is the final hurdle ....Limits Defined in PHP.
The upload functionality in CBB uses a PHP function called move_uploaded_file(). If you go look at the discussion attached to the documentation on this function over at www.php.net
, you will see that there are some settings in PHP that constrain file upload sizes. The two settings in particular that must change in this case are upload_max_filesize
You probably *DON'T* want to change these in php.ini as this is a very specialized case and you probably want the default for these in most cases. But in this instance, the value for these settings are going to have to go up. These settings cannot be programtically overridden at runtime, so forget about hacking upload.php. You *CAN* however, override them with directives in an .htaccess file in your XOOPS directory. So, if you want to bump the limit up to 50 meg, you would create an .htaccess file (or add to an existing one) as follows:
php_value upload_max_filesize 50M
php_value post_max_size 50M
The above assumes you are running PHP4 and will bump your limit up to 50 Meg.
I uploaded a 7 Meg file with no other mods than what I've outlined above. The discussion of move_uploaded_file() also talks about possibly having to bump up max_input_time and max_execution_time. My upload ran about 1.5 minutes and I did not have to touch either of those; your mileage may vary. There was also discussion about possibly needing to bump up memory_limit. I didn't have to for my 7 Meg file. There is not a whole lot of doc on php.net on memory_limit. I did find this
. The default is 128M; be *VERY* careful messing with it.
There are probably dozens of reasons why none of this is a good idea, but if you have a limited number of users, control of your server and you really need it, well, there you go ......