Php codeigniter can';t将图片上载到文件夹

Php codeigniter can';t将图片上载到文件夹,php,image,codeigniter,upload,Php,Image,Codeigniter,Upload,我需要帮助上传文件夹中的图片。事情是这样的,我以前已经测试过了,它很有效。过了一段时间,我再次测试了一下,突然发现它不起作用了。我真的不能直接思考,请帮帮我 我的看法是: <?php echo form_open_multipart("adminFolder/admin/insert_picture"); echo form_upload("userfile", "Gambar Picture"); echo form_submit("

我需要帮助上传文件夹中的图片。事情是这样的,我以前已经测试过了,它很有效。过了一段时间,我再次测试了一下,突然发现它不起作用了。我真的不能直接思考,请帮帮我

我的看法是:

<?php 
        echo form_open_multipart("adminFolder/admin/insert_picture");

        echo form_upload("userfile", "Gambar Picture");

        echo form_submit("input_picture", "Input now !!!");

        ?>
我的模型:

function doUpload(){
        $path = './assets/images/';
        chmod($path, 0777);

        $config['upload_path'] = $path; 
        $config['allowed_types'] = 'gif|jpg|png|jpeg'; 
        $config['max_size'] = '6000'; 
        $config['max_width']  = '1024';
        $config['max_height']  = '768'; 
        $config['overwrite'] = TRUE;

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

        if(!$this->upload->do_upload()){
            redirect("adminFolder/admin/insertPicture");
        }else{

            redirect("adminFolder/admin/adminPic");
        }


    }

您应该要求在do_upload中传递文件名:

因此,您的模型代码为:

  if(!$this->upload->do_upload('userfile')){
        redirect("adminFolder/admin/insertPicture");
    }else{

        redirect("adminFolder/admin/adminPic");
    }
这就行了!!请尝试在视图中使用:

输入type=“file”multiple=“multiple”id=“userfile”name=“userfile”

控制器
在控制器方法中添加此行
$this->gallery\u model->do\u upload($data)

创建一个模型类“gallery\u模型”
如果你需要多个图片上传,我也可以粘贴代码

我试过了,还是一样,有趣的是,我把准确的代码复制到另一个空项目中,它成功了,但在我的主项目中不起作用,不知道该说什么请编写echo$this->upload->display_errors();出口在if代码内部和重定向行之前,它将在上载时回显错误
  if(!$this->upload->do_upload('userfile')){
        redirect("adminFolder/admin/insertPicture");
    }else{

        redirect("adminFolder/admin/adminPic");
    }
var $gallery_path;
var $gallery_path_url;

function Gallery_model() {
    parent::__construct(); 

    $this->gallery_path = realpath(APPPATH . '../images');
    $this->gallery_path_url = base_url().'images/';

}

function do_upload() {

    $config = array(
        'allowed_types' => 'jpg|jpeg|gif|png',
        'upload_path' => $this->gallery_path,
        'max_size' => 2000
    );

    $this->load->library('upload', $config);
    $this->upload->do_upload();
    $image_data = $this->upload->data();

    $config = array(
        'source_image' => $image_data['full_path'],
        'new_image' => $this->gallery_path . '/thumbs',
        'maintain_ration' => true,
        'width' => 150,
        'height' => 100
    );

    $this->load->library('image_lib', $config);
    $this->image_lib->resize();

}

function get_images() {

    $files = scandir($this->gallery_path);
    $files = array_diff($files, array('.', '..', 'thumbs'));

    $images = array();

    foreach ($files as $file) {
        $images []= array (
            'url' => $this->gallery_path_url . $file,
            'thumb_url' => $this->gallery_path_url . 'thumbs/' . $file
        );
    }

    return $images;
}