dongzhi5386 2010-08-19 04:46
浏览 98
已采纳

使用codeigniter上传PDF文件

Hi I'm very new to stackoverflow and codeigniter so I apologize if I'm breaking any rules or etiquette with this question (I did a search of the related questions and didn't see anything that related directly to my question).

I'm trying to upload a PDF file, and I'm using the following code (codeigniter version 1.7.2):

    function test(){
        $this->load->library('upload');   
        $config['upload_path'] = './assets/certificates/';
        $config['allowed_types'] = 'pdf';
        $config['max_size']    = '1000000';
        $config['file_name'] = "test";

        $this->upload->initialize($config);
        $certificateflag = $this->upload->do_upload("certificate");       
        if ($this->upload->do_upload("certificate"))
            error_reporting(E_ALL);
        else{
            echo "<pre>"; Print_r($this->upload->data()); echo "</pre>";
        }
}

I don't get any errors, and it appears that the file gets uploaded, but it doesn't appear in the directory, and I can't find it anywhere on the server. The output from the above gives me the path of where the file should be,but it's not there.

I'm using almost the exact block of code in another part for jpg files that I upload to the same directory and that works fine.

Any help/ideas are greatly appreciated.

  • 写回答

1条回答 默认 最新

  • doufud21086 2010-08-19 16:49
    关注

    at first as I see you are calling method do_upload twice, I think you need to delete one of them. after do_upload call try to call $this->upload->display_errors() method it can give you some errors. recheck the field name it should be "certificate" and check the chmod of './assets/certificates/' it should be 777. hope this helps.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器