function get_upload_file($tag_name, $type = 'all') { $files_list = transposed_all_files_array($_FILES); $list = element($tag_name, $files_list, array()); if ($type == 'one') { if (count($list)) { return $list[0]; } else { return null; } } else { if (count($list)) { return $list; } else { return array(); } } }
public static function file($index = null) { if (!$_FILES) { return array(); } if (!function_exists('get_upload_file') || !function_exists('transposed_all_files_array')) { self::ci()->load->helper('oa'); } if ($index === null) { return transposed_all_files_array($_FILES); } preg_match_all('/^(?P<var>\\w+)(\\s?\\[\\s?\\]\\s?)$/', $index, $matches); if ($matches = $matches['var'] ? $matches['var'][0] : null) { return get_upload_file($matches); } else { return get_upload_file($index, 'one'); } }