为了账号安全,请及时绑定邮箱和手机立即绑定

上传的文件的临时名称未进入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 关注
  • 120 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号