为了账号安全,请及时绑定邮箱和手机立即绑定

我在将文件移动到我想要的文件夹时遇到问题

我在将文件移动到我想要的文件夹时遇到问题

PHP
UYOU 2021-06-15 22:01:05
我需要将我的文件移动到我想要的位置,但我的文件没有移动到文件夹中,所以请帮助我。   Here is the code of my controller "Sms_Controller".           $pic_file1 = $this->input->post('pic_file');    $pic_file1 = str_replace( "\\", '/', $pic_file1);    $filename = basename($pic_file1);        $config['upload_path']          = BASEPATH. '../assets/uploads/';        $config['allowed_types']        = 'gif|jpg|png';        $config['max_size']             = 1000;        $this->load->library('upload', $config);        if ( ! $this->upload->do_upload('pic_file')){            $error = array('error' => $this->upload->display_errors());            $this->load->view('reg_dsa', $error);        }else{            //file is uploaded successfully            //now get the file uploaded data             $upload_data = $this->upload->data();            //get the uploaded file name        }
查看完整描述

2 回答

?
心有法竹

TA贡献1866条经验 获得超5个赞

请替换此代码


                $config['upload_path']          = './assets/uploads/';

                $config['allowed_types']        = 'gif|jpg|png';

                $config['max_size']             = 100;

                $config['max_width']            = 1024;

                $config['max_height']           = 768;


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


                if ( ! $this->upload->do_upload('pic_file'))

                {

                        $error = array('error' => $this->upload->display_errors());

                        print_r($error);


                }

                else

                {

                        $data = array('upload_data' => $this->upload->data());

                        print_r($data);


                }

                die; 


查看完整回答
反对 回复 2021-06-19
?
HUX布斯

TA贡献1876条经验 获得超6个赞

以下是将文件从网站根目录和根目录中的uploadFolder上传到所需文件夹的通用代码。


/*------------------------ File Upload --------------------------- */



        $config['upload_path'] = './uploadFolder/';

        $config['allowed_types'] = 'pdf|jpg|jpeg|png';

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

        $filename = "";

        if (!$this->upload->do_upload('filename')) {

            //$this->session->set_flashdata('error_msg', $this->upload->display_errors());

        } else {

            $data1 = array('upload_data' => $this->upload->data());

            $filename = "" . $data1["upload_data"]["file_name"];

        }


$filename is the Filename required to store in the database


查看完整回答
反对 回复 2021-06-19
  • 2 回答
  • 0 关注
  • 162 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号