我正在更新图片文件,但是当我更新新版本时,它会替换旧版本。我想保留所有图片文件而不更换。
例如
如果我删除其中一个并添加新的一个,则用一个更新列值并删除旧的..我需要所有这些。
此处我的上传代码:
$picture=array();
$cpt = count($_FILES['my_image_upload']['name']);
$config['upload_path'] = APPPATH.'uploads/';
$config['allowed_types'] = '*';
$files = $_FILES;
for($i=0; $i<$cpt; $i++)
{
if($_FILES['my_image_upload']['name'][$i]!='')
{
$_FILES['my_image_upload']['name']= $files['my_image_upload']['name'][$i];
$_FILES['my_image_upload']['type']= $files['my_image_upload']['type'][$i];
$_FILES['my_image_upload']['tmp_name']= $files['my_image_upload']['tmp_name'][$i];
$_FILES['my_image_upload']['error']= $files['my_image_upload']['error'][$i];
$_FILES['my_image_upload']['size']= $files['my_image_upload']['size'][$i];
$this->load->library('upload', $config);
$this->upload->initialize($config);
$upload= $this->upload->do_upload('my_image_upload');
if($upload)
{
$this->upload->data();
$picture[] =$_FILES['my_image_upload']['name'];
}
}
}
$fileName = implode('|',$picture);
提前致谢..
答案 0 :(得分:0)
我建议像这样创建新表并插入数据......
id user_id image_name
1 2 abc.jpg
2 2 bbb.jpg
3 2 ccc.jpg
.........
以简单的方式插入,更新和删除,如您所愿