"Invalid filename." error is shown when a valid filename is uploaded. We are using PHP 5.2.1 and mysql5. It seems that the problem is on line 240:

$file['name'] = substr($file['name'], -48); //max filename lenght is 48

The substr returns and empty string when then length of the filename is less than 48, and therefore the error is raised.

On PHP 5.2.0 works perfectly, but in 5.2.1 not. It may be an undocumented change or bug on this release of PHP.

Comments

ufku’s picture

Priority: Critical » Normal

not verified! and since it seems to be related to a certain php version it is not critical.
a quickfix for the ones having the issue could be changing the buggy line with:
$file['name'] = strlen($file['name'])>48 ? substr($file['name'], -48) : $file['name'];

patch comes later.

thanks juanval.

ufku’s picture

Status: Active » Closed (fixed)

this was reported many times and fixed in a lately submitted issue.

giorgosk’s picture

Status: Closed (fixed) » Active

OK that fix was still needed for my current installation of

imce 5.x-1.x-dev
drupal 5.10
PHP 5.2.6

ufku’s picture

Status: Active » Closed (won't fix)