我有两个输入字段,如下所示;
library(ggplot2)
library(dplyr)
m1 %>%
group_by(SEGMENT) %>%
top_n(10, Calculated_Potential) %>%
ggplot(aes(reorder(ACCOUNT_NAME, Calculated_Potential), Calculated_Potential/10^6)) +
geom_col() +
theme(axis.text.x = element_text(angle = -90, hjust = 0)) +
facet_grid(~ SEGMENT, scales = "free_x")
如何使用foreach上传两个文件?我尝试了几种方法,但我无法实现。
谢谢
答案 0 :(得分:0)
好吧,如果您坚持使用参数和输入名称来保持它不变,那么就必须在$_FILES
之前重组do_upload()
数组:
public function upload()
{
$count = count($_FILES['datainfo']['name']);
for ($i=0; $i < $count; $i++)
{
foreach ($_FILES['datainfo'] as $key1 => $value1)
{
foreach ($value1 as $key2 => $value2)
{
$files[$key2][$key1] = $value2;
}
}
}
$_FILES = $files;
$config['upload_path'] = FCPATH.'uploads/';
$config['allowed_types'] = 'gif|jpg|jpeg|png';
$config['max_size'] = '2048';
$config['max_width'] = '1920';
$config['max_height'] = '1280';
$this->load->library('upload', $config);
foreach ($_FILES as $fieldname => $fileObject)
{
if (!empty($fileObject['name']))
{
$this->upload->initialize($config);
if (!$this->upload->do_upload($fieldname))
{
$errors = $this->upload->display_errors();
}
else
{
$success = 'Success';
}
}
}
}
我已经在您输入的环境中对它进行了测试,并且效果很好。