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

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

Code Igniter 文件上傳,無法上傳 pdf 和 doc,結果沒有上傳文件,沒有錯誤

Code Igniter 文件上傳,無法上傳 pdf 和 doc,結果沒有上傳文件,沒有錯誤

PHP
RISEBY 2023-10-01 15:46:41
我第一次使用上傳圖像,效果很好。然后我想升級上傳 pdf、doc 和 xls。圖像和 xls 有效, upload_folder中有該文件,并且該文件可以下載。當我嘗試上傳 pdf 和文檔時出現問題,文件未上傳到upload_folder 這是我的代碼:啞劇.php'pdf'   =>  array('application/pdf', 'application/force-download', 'application/x-download', 'binary/octet-stream'),core.php 用于下載文件function download($src){    $this->load->helper('download');    force_download('uploads/'.$src, NULL);}insert.php 用于上傳文件function insert(){                $id_car_header  = $this->input->post('input_id_car_header');        $keterangan     = $this->input->post('input_keterangan');        $arsip = $_FILES["input_arsip"]['name'];               if ($arsip ='')        {}        else        {               $config ['allowed_types']   = 'jpg|jpeg|png|docx|pdf|xls';            $arsip_generate =$_FILES["input_arsip"]['name'];            $config ['upload_path']     = './uploads';            $config['file_name'] = $arsip_generate;                    $this->load->library('upload', $config);                    $this->load->library('upload', $config);                //$this->upload->initialize($config);                if (!$this->upload->do_upload('input_arsip'))                     {                         //$this->upload->display_errors();                       echo "Gambar Gagal DiUpload..!!";                    } else{                            $arsip = $this->upload->data('file_name');                    }        }        $data = array        (            'id_car_header' => $id_car_header,            'ket_arsip'    =>  $keterangan,            'datas'        =>  $arsip        );        $check = $this->m_db->insertDataAll("tbl_car_arsip", $data);        $this->checkInsert($check);         }我試圖更改我的 mime.php、初始化并更改結構代碼,但所有這些都不起作用有人可以告訴我需要做什么才能使我的代碼能夠上傳 pdf 和文檔嗎?非常感謝
查看完整描述

1 回答

?
牛魔王的故事

TA貢獻1830條經驗 獲得超3個贊

我不知道為什么在關閉我的筆記本電腦并稍微更改代碼后會起作用,所有大尺寸的文件都可以上傳和下載 ofc 我更改了 Stackoverflow 上一些像我一樣有問題的用戶的代碼,謝謝


我認為這個可以使上傳的 pdf 起作用,我更改了這一行


   $config ['allowed_types']   = '*';

這是上傳文件的更新,我只改變了這個功能


$id_car_header  = $this->input->post('input_id_car_header');

        $keterangan     = $this->input->post('input_keterangan');

        $arsip = $_FILES["input_arsip"]['name'];

      

            $config ['allowed_types']   = '*';

            $arsip_generate =$_FILES["input_arsip"]['name'];

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

            $config['file_name'] = $arsip_generate;

            $config['max_size'] = 2000000;

            $config['max_width'] = 1500;

            $config['max_height'] = 1500;

            

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

                    $this->upload->initialize($config, true);

                    //$this->upload->initialize($config);

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

                        {

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

                            $this->upload->display_errors();

                             //$this->upload->display_errors() 

                            echo "Gambar Gagal DiUpload..!!";

                            var_dump($config);

                    } else{

                            

                            $arsip = $this->upload->data('file_name');

                            $data = array

                                (

                                    'id_car_header' => $id_car_header,

                                    'ket_arsip'    =>  $keterangan,

                                    'datas'        =>  $arsip

                                );

                    $check = $this->m_db->insertDataAll("tbl_car_arsip", $data);

                    $this->checkInsert($check); 

 

                    }


查看完整回答
反對 回復 2023-10-01
  • 1 回答
  • 0 關注
  • 87 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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