【发布时间】:2015-08-16 10:55:05
【问题描述】:
我使用 codeigniter 并且在上传文件时遇到问题。 file_name 是重复产生的。
我的模型: (db_category)
public function do_upload($route = "./category-pic/") {
$config = array(
'allowed_types' => 'jpg|jpeg|gif|png',
'upload_path' => $route,
'encrypt_name' => 'TRUE',
'max_size' => 3000
);
$this->load->library("upload", $config);
}
我的控制者:
$this->db_category->do_upload("./product-pic/");
foreach ($_FILES as $key => $value) {
$this->upload->do_upload($key);
$data_name = $this->upload->data();
$k++;
if (is_uploaded_file($_FILES['file'.$k]['tmp_name'])) {
// This is produced Repetitiously sometimes for different pictures.
echo $data_name['file_name']. " ****** ";
}
}
我的观点简单而静态,例如:
echo '<input type="file" name="file1" id="my_uploader" style="width: 210px;" />' ;
echo '<input type="file" name="file2" id="my_uploader" style="width: 210px;" />';
echo '<input type="file" name="file3" id="my_uploader" style="width: 210px;" />';
echo '<input type="file" name="file4" id="my_uploader" style="width: 210px;" />';
注意:所有图片都可以上传自己的名字,但问题出在$data_name['file_name']。
有什么问题?谢谢。
【问题讨论】:
标签: php codeigniter image-uploading