开发者

uploading PDF files with codeigniter

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';
        $confi开发者_高级运维g['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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜