亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

我在將文件移動到我想要的文件夾時遇到問題

我在將文件移動到我想要的文件夾時遇到問題

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 關注
  • 192 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號