0
因此,我的表单中有四个输入文件,并使用以下索引将其发送到全局$ _FILES上:前,后,右和左。在Codeigniter中使用不同的输入文件上传多个图像
我想上传这些使用codeigniter图像类库。这是我的代码:
public function upload_to_temp($id, $folder, $tags){
$path = realpath(APPPATH . '../public/resources/temps/' . $folder);
//makes a directory
mkdir($path . '/' . $id, 0700);
//navigate to the newly created path
$path = realpath(APPPATH . '../public/resources/temps/' . $folder . '/' . $id);
if(isset($tags)){
//use these tags to check the files present on submission
foreach($tags as $tag){
if(array_key_exists($tag,$_FILES)){
if(!empty($_FILES) && $_FILES[$tag]["name"] != "" && isset($_FILES[$tag]["name"])){
$config = array (
'source_image' => $_FILES[$tag]["name"],
'image_library' => 'gd',
'upload_path' => $path,
'file_name' => $id . '_' . $tag . '.jpg',
'allowed_types' => 'png|jpg|jpeg',
'overwrite' => TRUE,
'max_size' => '2000',
);
$this->_CI->upload->initialize($config);
if(!$this->_CI->upload->do_upload()){
echo 'Error creating image. ';
echo $this->_CI->upload->display_errors();
}else{
echo 'Success saving to temp folder';
}
//kapag failed
if(!$this->_CI->upload->do_upload()){
echo 'Error creating image.';
echo $this->_CI->upload->display_errors();
}else{
//now, the $path will become our resource path for copying and creating thumbnails.
$resouce_path = $config['upload_path'] . '/' . $config['file_name'];
$this->img_create_thumb($resouce_path, $folder);
}
}else{
//Hindi na dapat marating to!
echo $tag . ' not present ';
}
}else{
//use default pictures
echo $tag . ' not present ';
}
}
}
}
但是它给了我下面的错误:
Error creating image.
You did not select a file to upload.
Error creating image.You did not select a file to upload.
You did not select a file to upload.
Error creating image.You did not select a file to upload.
Error creating image.You did not select a file to upload.
You did not select a file to upload.
right not present left not present
我觉得我没有正确指定哪些资源上的$ _FILES应该被上传。
您的回应将不胜感激。
感谢
你问了一个问题,自己回答这个问题吗?如果你看一下CI或搜索文档您的问题,您会找到很多答案。 –