我第一次使用上传图像,效果很好。然后我想升级上传 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 和文档吗?非常感谢
牛魔王的故事