用户
 找回密码
 入住 CI 中国社区
搜索
查看: 1223|回复: 0
收起左侧

[HELP] CI如何实现doc文件的上传

[复制链接]
发表于 2015-12-17 16:42:33 | 显示全部楼层 |阅读模式
控制器
$config['upload_path'] ='./uploads/';
        $config['allowed_types'] = 'doc|xls';
        $config['max_size'] = '1000000';
        $config['max_width'] = '1024';
        $config['max_height'] = '768';
        $this->load->library('upload', $config);
         $this->upload->set_allowed_types('doc|xls|png');

if (!$this->upload->do_upload())
        {
            var_dump($this->upload->do_upload());
            //$error = array('error' => $this->upload->display_errors());
            //echo "<javascript type='text/javascript'>alert('上传失败');</javascript>";
            echo "error";
            //$this->load->view('upload_form', $error);
        }
        else
        {   
            $data = array('upload_data' => $this->upload->data());
            //echo "<javascript type='text/javascript'>alert('上传成功');</javascript>";
            echo "success";
            //$this->load->view('upload_success', $data);
        }

view
<?php echo form_open_multipart($url);?>
    <ul class="forminfo">
    <li><label>文章标题</label><input name="" type="text" class="dfinput" /><i>标题不能超过30个字符</i></li>
    <li><label>关键字</label><input name="" type="text" class="dfinput" /><i>多个关键字用,隔开</i></li>
    <li><label>是否审核</label><cite><input name="" type="radio" value="" checked="checked" />是&nbsp;&nbsp;&nbsp;&nbsp;<input name="" type="radio" value="" />否</cite></li>
    <li><label>添加附件</label><input name="userfile" type="file" value="" /></li>
    <li><label>备注</label><textarea name="" cols="" rows="" class="textinput"></textarea></li>
    <li><label>&nbsp;</label><input name="" type="submit" class="btn" value="上传文档"/></li>



配置文件mimes.php
        'doc'        =>        'application/msword',
为什么总在
if ( ! @copy($this->file_temp, $this->upload_path.$this->file_name))
                {
                        if ( ! @move_uploaded_file($this->file_temp, $this->upload_path.$this->file_name))
                        {
                                $this->set_error('upload_destination_error');
                                return FALSE;
                        }
                }

这一步出错    求大神指导。

本版积分规则