Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/262.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Code Igniter文件上载,无法上载pdf和文档,结果未上载文件,无错误_Php_Codeigniter_File Upload_Codeigniter 3 - Fatal编程技术网

Php Code Igniter文件上载,无法上载pdf和文档,结果未上载文件,无错误

Php Code Igniter文件上载,无法上载pdf和文档,结果未上载文件,无错误,php,codeigniter,file-upload,codeigniter-3,Php,Codeigniter,File Upload,Codeigniter 3,我第一次用do上传我的图片,效果很好。 然后我想升级以上传pdf、doc和xls。 图像,xls工作,上传文件夹中有文件,文件工作下载 当我试图上传pdf和文档时,该文件没有上传到upload\u文件夹 这是我的代码: mimes.php 'pdf' => array('application/pdf', 'application/force-download', 'application/x-download', 'binary/octet-stream'), 下载文件的core

我第一次用do上传我的图片,效果很好。 然后我想升级以上传pdf、doc和xls。 图像,xls工作,上传文件夹中有文件,文件工作下载

当我试图上传pdf和文档时,该文件没有上传到upload\u文件夹 这是我的代码:

mimes.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);
}
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);     
    }
insert.php用于上传文件

function download($src)
{
    $this->load->helper('download');
    force_download('uploads/'.$src, NULL);
}
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);     
    }
我的布局为表单

<form action="<?php echo base_url().'/insert/insertArsip'; ?>" method="post" enctype="multipart/form-data">

                    <div class="col-md-12 col-xs-12">
                        <div class="form-group">
                            <input type="hidden" name="input_id_car_header" value="<?= $carHeader['id_car_header']?>">
                           
                             <label class="control-label col-md-3 col-sm-3 col-xs-12">File/Foto </label>
                            <div class="col-md-9 col-sm-9 col-xs-12">
                                
                               <input type="file" name="input_arsip" class="form-control">
                            </div>
                        </div>
                       
                        <div class="form-group">
                            <label class="control-label col-md-3 col-sm-3 col-xs-12">Keterangan </label>
                            <div class="col-md-9 col-sm-9 col-xs-12">

                                <textarea name="input_keterangan" required="required" class="form-control" rows="3" placeholder="Masukan Keterangan"></textarea>
                            </div>
                        </div>
                        
                        <div class="ln_solid"></div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-9 col-sm-9 col-xs-12 col-md-offset-3">
                           
                                <button type="submit" class="btn btn-success pull-right">
                                    <i class="fa fa-save"></i> Save
                                </button>
                            
                        </div>
                    </div>
</form>

我不知道为什么在关闭我的笔记本电脑并稍微更改代码后,所有大文件都可以上传和下载
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); 
 
                    }

我不知道为什么在关闭我的笔记本电脑并稍微更改代码后,所有大文件都可以上传和下载 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); 
 
                    }

请从标题中删除[已解决],并用您的发现创建一个答案:看,我已经更改了它,也许您有不同的解决方法。现在,请将工作代码作为答案,并解释您已更改的内容,使其正常工作。是的,我不知道这是否是澄清我的问题的更好方法,谢谢。现在,我的代码可能可以帮助其他像我这样有问题的人。请从标题中删除[已解决],并用您的发现创建一个答案:看,我已经更改了它,也许您有不同的解决方法。现在,请将工作代码作为答案,并解释您所做的更改使其正常工作。是的,我不知道这是否是澄清我问题的更好方式,谢谢。现在我的代码也许可以帮助像我这样有问题的人