上传 codeigniter 时重复文件到 2 份副本
Repeat the file to 2 copise while upload codeigniter
在 CodeIgniter 中,当我将文件上传到特定文件夹时,它会上传该文件的两个副本
到文件夹。我的意思是,它重复文件,我不知道为什么。
我该如何解决这个问题?
谢谢。
控制器:
$config['upload_path'] = './files/';
$config['allowed_types'] = 'gif|jpg|png|jpeg|svg|rar|zip' ;
$config['max_size'] = 220048;
$config['encrypt_name'] = TRUE;
$this->load->library('upload', $config, 'catalogupload3');
// Create custom object for catalog upload
$this->catalogupload3->initialize($config);
$this->catalogupload3->do_upload('userfile5');
if (!$this->catalogupload3->do_upload('userfile5')){
$url_file = 'nofile' ;
$file_name = 'false';
$file_size = 'false';
}else {
$this->catalogupload3->data();
$url_file = $this->catalogupload3->data('file_name');
$file_name = $_FILES['userfile5']['name'];
$file_size = $_FILES['userfile5']['size'];
}
////
$config['upload_path'] = './files/32/';
$config['allowed_types'] = 'gif|jpg|png|jpeg|svg|rar|zip' ;
$config['max_size'] = 220048;
$config['encrypt_name'] = TRUE;
$this->load->library('upload', $config, 'catalogupload5');
// Create custom object for catalog upload
$this->catalogupload5->initialize($config);
$this->catalogupload5->do_upload('userfile7');
if (!$this->catalogupload5->do_upload('userfile7')){
$url_file = 'nofile' ;
}else {
$this->catalogupload5->data();
$url_file_32 = $this->catalogupload5->data('file_name');
}
当然会上传两份因为你运行函数两次:
// first run
$this->catalogupload3->do_upload('userfile5');
// second run
if (!$this->catalogupload3->do_upload('userfile5'))
如果你想检查一次:
// this is enough it will run it and return a bool
if (!$this->catalogupload3->do_upload('userfile5'))
在 CodeIgniter 中,当我将文件上传到特定文件夹时,它会上传该文件的两个副本 到文件夹。我的意思是,它重复文件,我不知道为什么。 我该如何解决这个问题? 谢谢。
控制器:
$config['upload_path'] = './files/';
$config['allowed_types'] = 'gif|jpg|png|jpeg|svg|rar|zip' ;
$config['max_size'] = 220048;
$config['encrypt_name'] = TRUE;
$this->load->library('upload', $config, 'catalogupload3');
// Create custom object for catalog upload
$this->catalogupload3->initialize($config);
$this->catalogupload3->do_upload('userfile5');
if (!$this->catalogupload3->do_upload('userfile5')){
$url_file = 'nofile' ;
$file_name = 'false';
$file_size = 'false';
}else {
$this->catalogupload3->data();
$url_file = $this->catalogupload3->data('file_name');
$file_name = $_FILES['userfile5']['name'];
$file_size = $_FILES['userfile5']['size'];
}
////
$config['upload_path'] = './files/32/';
$config['allowed_types'] = 'gif|jpg|png|jpeg|svg|rar|zip' ;
$config['max_size'] = 220048;
$config['encrypt_name'] = TRUE;
$this->load->library('upload', $config, 'catalogupload5');
// Create custom object for catalog upload
$this->catalogupload5->initialize($config);
$this->catalogupload5->do_upload('userfile7');
if (!$this->catalogupload5->do_upload('userfile7')){
$url_file = 'nofile' ;
}else {
$this->catalogupload5->data();
$url_file_32 = $this->catalogupload5->data('file_name');
}
当然会上传两份因为你运行函数两次:
// first run
$this->catalogupload3->do_upload('userfile5');
// second run
if (!$this->catalogupload3->do_upload('userfile5'))
如果你想检查一次:
// this is enough it will run it and return a bool
if (!$this->catalogupload3->do_upload('userfile5'))