Bug #13405: Multiple File-Upload Problem
| From: | leonhard dot holz at t-online dot de | Date: | Sun, 23 Sep 2001 14:12:17 +0000 |
| Subject: | Bug #13405: Multiple File-Upload Problem | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-66395@lists.php.net to get a copy of this message | ||
From: leonhard.holz@t-online.de
Operating system:
PHP version: 4.0.5
PHP Bug Type: Scripting Engine problem
Bug description: Multiple File-Upload Problem
It's just like Bug #5836, but with the "_name" - Array. If you have a
couple of files to upload and the first is not set, then the array
${file."_name"} has only one key (index 0) with the name of the second (!)
file.
So when you loop through the file-array the wrong name is attached to the
uploaded file.
Following function solves the problem:
function correctFileUploadBug($fp_sVarName) {
GLOBAL ${$fp_sVarName}, ${$fp_sVarName."_name"};
$aFile = &${$fp_sVarName};
$aFileName = &${$fp_sVarName."_name"};
$aNewFileName = Array();
$j = 0;
for ($i=0;$i<count($aFile);$i++) {
if (trim($aFile[$i]) == "" || trim($aFile[$i]) == "none") {
$aNewFileName[] = "";
$j++;
} else {
$aNewFileName[] = $aFileName[$i-$j];
}
}
unset($aFile);
unset($aFileName);
${$fp_sVarName."_name"} = $aNewFileName;
}
--
Edit bug report at: http://bugs.php.net/?id=13405&edit=1