我想上传一些文件。我使用codeigniter:
Html:
<input type="file" name="file1" />
<input type="file" name="file2" />
php:
$config['upload_path'] = './upload/';
$path = $config['upload_path'];
$config['allowed_types'] = 'gif|jpg|jpeg|png';
$config['encrypt_name'] = 'TRUE';
$this->load->library('upload', $config);
foreach ($_FILES as $key => $value) {
if (!empty($value['tmp_name']) && $value['size'] > 0) {
if (!$this->upload->do_upload($key)) {
// some errors
} else {
// Code After Files Upload Success GOES HERE
$data_name = $this->upload->data();
echo $data_name['file_name'];
}
}
}
当我想要echo
文件名时,我得到1.jpg
and 2.jpg
。但我想将它们分开并将它们插入数据库。
我怎样才能做到这一点?谢谢 :)