pear uploader

From: Date: Thu, 26 Sep 2002 05:59:10 +0000
Subject: pear uploader
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-2388@lists.php.net to get a copy of this message
dont know where to add this but i made a change that might be helpful, say i had 5 input boxes and only one file was uploaded the uploader would still go through file arrays, i added a check to see if they are empty or not , so if i upload one file there is only one in the array not 5 , handy for the progress bar implemented function &_buildFiles() { // Form method check if (!ereg('^multipart/form-data', $this->content_type)) { return $this->raiseError('BAD_FORM'); } // In 4.1 HTTP_POST_FILES isn't initialized when no uploads if (function_exists('version_compare') && version_compare(phpversion(), '4.1', 'ge')) { $error = $this->isMissing(); if (PEAR::isError($error)) { return $error; } } // Parse $HTTP_POST_FILES $files = array(); foreach ($this->post_files as $userfile => $value) { if (is_array($value['name'])) { foreach ($value['name'] as $key => $val) { //check for empty value - update ??? if ($val !==""){ $name = basename($value['name'][$key]); $tmp_name = $value['tmp_name'][$key]; $size = $value['size'][$key]; $type = $value['type'][$key]; $formname = $userfile . "[$key]"; $files[$formname] = new HTTP_Upload_File($name, $tmp_name, $formname, $type, $size, $this->lang); } // } // One file } else { $name = basename($value['name']); $tmp_name = $value['tmp_name']; $size = $value['size']; $type = $value['type']; $formname = $userfile; $files[$formname] = new HTTP_Upload_File($name, $tmp_name, $formname, $type, $size, $this->lang); } } return $files; }

« previous php.pear.general (#2388) next »