file.inc uses constants that only exist in PHP 4.3 or higher (http://nl.php.net/manual/en/features.file-upload.errors.php) causing file uploads to fail in PHP 4.2.

Comments

dries’s picture

Committed to HEAD. Thanks.

gábor hojtsy’s picture

This should be wrapped in an if (defined('UPLOAD_ERR_OK')) IMHO, since after this patch, the code will not work with PHP 4.3+ :)

bart jansens’s picture

StatusFileSize
new853 bytes

Unfortunatly i'm not seeing the notices but the attached patch should fix this :)

ax’s picture

tested and working (no more notices). please apply.

magico’s picture

I think that is better to check for PHP version instead of checking for one constant definition.

// Required for file uploads to work with PHP 4.2
if (version_compare(phpversion(), '4.2.0', '<='))
{
define('UPLOAD_ERR_OK', 0);
define('UPLOAD_ERR_INI_SIZE', 1);
define('UPLOAD_ERR_FORM_SIZE', 2);
define('UPLOAD_ERR_PARTIAL', 3);
define('UPLOAD_ERR_NO_FILE', 4);
}

Anonymous’s picture

Nope. Since we define the constants, they only need to be defined, if they are not defined yet. You do the same with functions...

if (!function_exists('file_get_contents')) {
  function file_get_contents(...) {
    ...
  }
}

Checking for PHP version is odd... Only the constants are the problem as the reported indicated. Please apply Bart's patch.

Anonymous’s picture

Kjartan’s picture

This should be fixed in CVS:

Anonymous’s picture