【问题标题】:codeigniter how to upload picture to folder, web/assets/picture/codeigniter如何将图片上传到文件夹,web/assets/picture/
【发布时间】:2015-04-10 14:32:07
【问题描述】:

我正在使用 codeigniter,我想将文件图片上传到我的文件夹, 路径是web/assets/picture/

我看过这里,但无法用我找到的答案来修复它。请帮忙。

这是我在哪里输入图片的视图:

echo form_open_multipart("adminFolder/admin/insert_picture");   
echo form_upload("userfile", "Gambar Picture"); 
echo form_submit("input_picture", "Input now !!!");

我的控制器 insert_picture :

        if($this->input->post("userfile")){
            $this->model_get->doUpload();

            $this->adminPic();
        }else{
            $this->insertPicture();
        }

我的模特:

function doUpload(){

        $config['upload_path'] = '../assets/images/'; 
        $config['allowed_types'] = 'gif|jpg|png|jpeg'; 
        $config['max_size'] = '2048'; 
        $config['max_width']  = '1024';
        $config['max_height']  = '768'; 
        $config['overwrite'] = TRUE;

        $this->load->library("upload", $config);
        $this->upload->do_upload(); 
    }

【问题讨论】:

    标签: php image file codeigniter upload


    【解决方案1】:

    将您的 upload_path 设置为:

    $config['upload_path'] = FCPATH . 'web/assets/picture/';
    

    FCPATH 常量返回主目录的路径。

    确保目录存在且可写。

    【讨论】:

    • 我如何检查目录的权限??我该如何改变它??
    猜你喜欢
    • 1970-01-01
    • 2015-06-17
    • 1970-01-01
    • 2013-07-27
    • 1970-01-01
    • 2012-06-13
    • 2014-02-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多