上传多次运行

时间:2012-10-15 15:02:09

标签: php upload

我有一个运行的应用程序,允许用户上传.zip文件。 一切运行顺畅,但不知何故上传运行多次。 我用谷歌搜索,搜索stackoverflow,但是当我读取我的代码时,它不会多次运行do_upload()函数,只在if子句中运行一次。

据我了解上传库, $这 - > upload->的display_errors() 和 $这 - > upload->数据() 不会再次运行上传,我是对的吗?

我的控制器:

    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>

0 个答案:

没有答案