我需要一些帮助来了解如何为保存在'上传'中的多张图片保存路径。表中的文件夹。我完全迷失在这里。
我有这个应用程序可以完美地上传多张图片,但它们并没有与db链接。
这是一个实际上是callback_函数的控制器:
private $_uploaded;
public function fileupload_check() {
$number_of_files = sizeof($_FILES['uploadedimages']['tmp_name']);
$files = $_FILES['uploadedimages'];
for($i=0;$i<$number_of_files;$i++) {
if($_FILES['uploadedimages']['error'][$i] != 0) {
$this->form_validation->set_message('fileupload_check', 'At least 1 image needed.');
return FALSE;
}
}
$this->load->library('upload');
$config['upload_path'] = FCPATH . 'uploads/';
$config['allowed_types'] = 'gif|jpg|png';
for ($i = 0; $i < $number_of_files; $i++) {
$_FILES['uploadedimage']['name'] = $files['name'][$i];
$_FILES['uploadedimage']['type'] = $files['type'][$i];
$_FILES['uploadedimage']['tmp_name'] = $files['tmp_name'][$i];
$_FILES['uploadedimage']['error'] = $files['error'][$i];
$_FILES['uploadedimage']['size'] = $files['size'][$i];
$this->upload->initialize($config);
if ($this->upload->do_upload('uploadedimage')) {
$this->_uploaded[$i] = $this->upload->data();
} else {
$this->form_validation->set_message('fileupload_check', $this->upload->display_errors());
return FALSE;
}
}
return TRUE;
}
如果我在表格中有一个字段&#39; images_path&#39;如何保存数据库中每个图像的路径?
提前致谢。
答案 0 :(得分:1)
if if condition尝试此代码。
$data['upload_data'] = $this->upload->data();
$image_name = $data['upload_data']['file_name'];
如果你打印这样的$ data:
echo "<pre>"; print_r($data);
你将获得整个数组,其中包括路径,名称,图像tyepe等。