我有一个正在运行的应用程序,它允许用户上传 .zip 文件。一切运行顺利,但不知何故,上传运行多次。我用谷歌搜索,搜索了stackoverflow,但是当我阅读我的代码时,它不会多次运行do_upload()函数,只在if子句中运行一次。
据我了解上传库, $this->upload->display_errors() 和 $this->upload->data() 不会再次运行上传,对吗?
我的控制器:
function upload()
{
$this->checkAuth();
$config['upload_path'] = '.\files\zipped\\';
$config['allowed_types'] = 'zip';
$config['max_size'] = '200000';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('\upload\v_import', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
$this->load->view('\upload\v_upload_sucess', $data);
$this->parse();
}
}
我的观点:
<?php echo $error;?>
<?php echo form_open_multipart('import/upload');
?>
<input type="file" name="userfile" size="100" />
<br /><br />
<input type="submit" value="upload" />
</form>
我的成功观:
<h3>Your file was successfully uploaded!</h3>
<ul>
<?php foreach ($upload_data as $item => $value):?>
<li><?php echo $item;?>: <?php echo $value;?></li>
<?php endforeach; ?>
</ul>
<p><?php echo anchor('import', 'Upload Another File!'); ?></p>