上传文件的临时名称未进入 blueimp jQuery 文件上传
temporary name of file uploaded not getting in blueimp jQuery file upload
我正在使用 blueimp jQuery 文件上传 uploader.This 是我的控制器代码。
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 as bool(true)。上传的文件名(ie.name 由上传库赋值)不是working.i想要得到的那些details.how得到它?如果有人知道请帮助。
$this->upload->do_upload('files');
returns 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'];
}
看看对你有没有帮助。
我正在使用 blueimp jQuery 文件上传 uploader.This 是我的控制器代码。
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 as bool(true)。上传的文件名(ie.name 由上传库赋值)不是working.i想要得到的那些details.how得到它?如果有人知道请帮助。
$this->upload->do_upload('files');
returns 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'];
}
看看对你有没有帮助。