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

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

上傳的文件的臨時名稱未進入blueimp jQuery文件上傳

上傳的文件的臨時名稱未進入blueimp jQuery文件上傳

PHP
SMILET 2023-07-15 18:34:09
我正在使用 blueimp jQuery 文件上傳作為文件上傳器。這是我的控制器代碼。public function savedocument() {        $response = array('status' => 'failed', 'message' => 'Unknown reason');        $config = array();        $config['upload_path'] = 'upload path';        $config['allowed_types'] = 'gif|jpg|png|pdf|doc|docx';        $config['max_size']      = '20480';        $config['overwrite']     = FALSE;    //var_dump($config);        $this->load->library('upload', $config);        $files = $_FILES;        for($i=0; $i< count($_FILES['files']['name']); $i++)        {                   $_FILES['files']['name']= $files['files']['name'][$i];        $_FILES['files']['type']= $files['files']['type'][$i];        $_FILES['files']['tmp_name']= $files['files']['tmp_name'][$i];        $_FILES['files']['error']= $files['files']['error'][$i];        $_FILES['files']['size']= $files['files']['size'][$i];            $this->upload->initialize($config);    if (!$this->upload->do_upload('files')) {                $response['message'] = $this->upload->display_errors();            } else {              $file_details = $this->upload->do_upload('files');                     $response['status'] = 'success';                $response['message'] = $file_details;    }        }    }我得到打印 $file_details 的值為 bool(true)。上傳的文件名(即上傳庫分配的名稱)不起作用。我想獲取這些詳細信息。如何獲取它?如果有人知道請幫助。
查看完整描述

1 回答

?
qq_笑_17

TA貢獻1818條經驗 獲得超7個贊

$this->upload->do_upload('files');true如果文件上傳正確則返回。你想要的可能是$this->upload->data()。另外,我建議更改文件名(不是必需的,但有助于調試)。下面是關于這個問題的工作代碼 -


for($i = 0; $i < count($_FILES['files']['name']); $i++){     


    $_FILES['user_file']['name']     = $_FILES['files']['name'][$i];

    $_FILES['user_file']['type']     = $_FILES['files']['type'][$i];

    $_FILES['user_file']['tmp_name'] = $_FILES['files']['tmp_name'][$i];

    $_FILES['user_file']['error']    = $_FILES['files']['error'][$i];

    $_FILES['user_file']['size']     = $_FILES['files']['size'][$i];

    

    $fileName = 'user_file';

}


$config['upload_path']   = 'your-path-here';

$config['allowed_types'] = 'gif|jpg|jpeg|png|GIF|JPG|PNG|JPEG';

$config['max_size']      = 6096;

$config['max_width']     = 1024;

$config['max_height']    = 768;

$config['encrypt_name']  = TRUE;

    

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

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


$uploaded = $this->upload->do_upload($fileName);

    

if ( ! $uploaded ){

      

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


}else{


    $upload_data = $this->upload->data(); // You'll get all the data of the uploaded file here.

    $file        = $upload_data['file_name'];

}

    

看看是否對你有幫助。


查看完整回答
反對 回復 2023-07-15
  • 1 回答
  • 0 關注
  • 145 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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