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 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog