我正在尝试使用带有以下代码的 codeigniter 框架上传压缩文件
function do_upload()
{
$name=time();
$config['upload_path'] = './uploadedModules/';
$config['allowed_types'] = 'zip|rar';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_view', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
$this->load->library('unzip');
// Optional: Only take out these files, anything else is ignored
$this->unzip->allow(array('css', 'js', 'png', 'gif', 'jpeg', 'jpg', 'tpl', 'html', 'swf'));
$this->unzip->extract('./uploadedModules/'.$data['upload_data']['file_name'], './application/modules/');
$pieces = explode(".", $data['upload_data']['file_name']);
$title=$pieces[0];
$status=1;
$core=0;
$this->addons_model->insertNewModule($title,$status,$core);
}
}
但主要问题是,当调用提取函数时,它会提取 zip,但结果是空文件夹。有没有办法克服这个问题?