我将文件上传到“临时”状态时出现问题。夹。 这是上传te文件的mij代码
//GET RANDOM STRING FOR TEMP FOLDER ATTACHMENT
$randompath = $this->generateRandomString(20);
$config['upload_path'] = "./include/upload/temps/$randompath/";
$config['allowed_types'] = 'gif|jpg|png|pdf|tiff';
$config['max_size'] = '2048';
$config['max_width'] = '0';
$config['max_height'] = '0';
$config['remove_spaces'] = true;
$fullpath = $config['upload_path'] . $_FILES['attachment']['name'];
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload('attachment'))
{
$cookie = array(
'name' => 'Attachment',
'value' => $fullpath
);
$this->input->set_cookie($cookie);
//return $fullpath;
return true;
}
else
{
return false;
}
我希望有人能帮助我解决这个问题。 文件夹权限是755 cookie也不是由下面的代码设置的
答案 0 :(得分:1)
上传文件夹 chmod 777
并成为固定位置示例
$config['upload_path'] = './upload/temp/'
。
能够将上传的数据放在某些地方。
$variable = $this->upload->data();
在形式的成功部分。
然后你可以执行此操作$variable['full_path']
http://www.codeigniter.com/user_guide/libraries
另外,我发现你没有$this->upload->initialize($config);
你需要做的配置工作,如用户指南中所述。
$file_upload = $this->upload->data();
$fullpath = $file_upload['full_path']
$filename = $file_upload['file_name']
所以$fullpath = $file_upload['full_path']
$config['upload_path'] = "./include/upload/temps";
$config['allowed_types'] = 'gif|jpg|png|pdf|tiff';
$config['max_size'] = '2048';
$config['max_width'] = '0';
$config['max_height'] = '0';
$config['remove_spaces'] = true;
$this->load->library('upload', $config);
$this->upload->initialize($config);
if ($this->upload->do_upload('attachment') == TRUE) {
$file_upload = $this->upload->data();
$cookie = array(
'name' => 'Attachment',
'value' => $file_upload['full_path']
);
$this->input->set_cookie($cookie);
$this->load->view('upload_success');
} else {
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_form', $error);
}