Codeigniter文件上传不上传
Codeigniter File upload not uploading
我无法将文件上传到 'temp' 文件夹。
这是上传 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 也不是由下面的代码设置的
上传文件夹 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);
}
我无法将文件上传到 'temp' 文件夹。 这是上传 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 也不是由下面的代码设置的
上传文件夹 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);
}