file could not be uploaded with PHP 5.3.8

Get help with installation and running phpBB 3.0.x here. Please do not post bug reports, feature requests, or MOD-related questions here.
Suggested Hosts
Forum rules
END OF SUPPORT: 1 January 2017 (announcement)
Locked
jerry3
Registered User
Posts: 2
Joined: Wed Sep 28, 2011 4:53 am

file could not be uploaded with PHP 5.3.8

Post by jerry3 »

Hi there

I use phhBB latest 3.0.9 release on IIS7.5. When using PHP 5.3.6 eveything works fine, but when switching to 5.3.8 I can not post anything, it says: file could not be uploaded. But I don't even try to upload anything... Is there any known problem with PHP 5.3.8 and phpBB on Windows? Any changes in file upload commands in PHP? And ideas?

Yours

Jerry
Messiah_of_Death
Registered User
Posts: 6
Joined: Fri Jun 21, 2002 11:05 am
Contact:

Re: file could not be uploaded with PHP 5.3.8

Post by Messiah_of_Death »

Since I don't get why I cannot add a comment to the bug-tracker (http://tracker.phpbb.com/browse/PHPBB3-10395) and I don't want mess up with "git" (I am just used to SVN, so it would take some time to make myself familar with "git" )

Anyways, I've just experienced the same problem and I tracked it down.
It happened on a Windows IIS with php 5.3.8, whenever you have enabled "attachments" the server will add "garbage" to the "$_FILES" array.

To fix this problem just alter the following file

phpBB3-root/includes/message_parser.php
function parse_attachments (around line 1361)

Code: Select all

		$upload_file = (isset($_FILES[$form_name]) && $_FILES[$form_name]['name'] != 'none' && trim($_FILES[$form_name]['name'])) ? true : false;
has to be changed to

Code: Select all

  $upload_file =  (
                                (isset($_FILES[$form_name])) 
                             && ($_FILES[$form_name]['name'] != 'none')
                             && (trim($_FILES[$form_name]['name']))
                             && (UPLOAD_ERR_OK == $_FILES[$form_name]['error']) 
                        ) ? true : false;
Well, at least do some checks on the error-field of "$_FILES". In this "bug" (may it be the server or the php-module) the variable always looks like this

Code: Select all

Array
(
    [fileupload] => Array
        (
            [name] => ʶ
            [type] => 
            [tmp_name] => 
            [error] => 4
            [size] => 0
        )

)
See the error-field? It's always set to "4" which is UPLOAD_ERR_NO_FILE. But as the original check is going for the name (which is garbage in this case) and way later on the error it will try to perform an "upload" (codewise) which will result in a void attempt.


Click here for reference: http://www.php.net/manual/en/features.f ... errors.php
jerry3
Registered User
Posts: 2
Joined: Wed Sep 28, 2011 4:53 am

Re: file could not be uploaded with PHP 5.3.8

Post by jerry3 »

Thanx for the tip! So changing the line you mentioned is enough to "fix" it? You told something about javascript checks, how do I do that?
Messiah_of_Death
Registered User
Posts: 6
Joined: Fri Jun 21, 2002 11:05 am
Contact:

Re: file could not be uploaded with PHP 5.3.8

Post by Messiah_of_Death »

I did not alter anything in the js-code. This is the only change necessary.
Locked

Return to “[3.0.x] Support Forum”