tập tin tải lên CodeIgniter tùy chọn ... hoạt động hoàn hảo .... . :)
khiển ---------- ---------
function file()
{
$this->load->view('includes/template', $data);
}
function valid_file()
{
$this->form_validation->set_rules('userfile', 'File', 'trim|xss_clean');
if ($this->form_validation->run()==FALSE)
{
$this->file();
}
else
{
$config['upload_path'] = './documents/';
$config['allowed_types'] = 'gif|jpg|png|docx|doc|txt|rtf';
$config['max_size'] = '1000';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
if (!$this->upload->do_upload('userfile',FALSE))
{
$this->form_validation->set_message('checkdoc', $data['error'] = $this->upload->display_errors());
if($_FILES['userfile']['error'] != 4)
{
return false;
}
}
else
{
return true;
}
}
tôi chỉ sử dụng dòng này mà làm cho nó tùy chọn,
if($_FILES['userfile']['error'] != 4)
{
return false;
}
$_FILES['userfile']['error'] != 4 is for file required to upload.
bạn u có thể làm cho nó unneccessory bằng cách sử dụng $_FILES['userfile']['error'] != 4
, sau đó nó sẽ vượt qua lỗi này cho tập tin cần thiết và hoạt động tốt với các loại sai sót nếu có bằng cách sử dụng trở lại sai, hy vọng nó hoạt động cho u ....
Nguồn
2013-05-11 12:50:12
sử dụng nó ở đâu? tại sao nó khó khăn như vậy để gõ một chút nữa để giải thích nơi nó đi ... – serdarsenay
Tôi chắc chắn trong bộ điều khiển, trước khi codeigniters tải lên rutine được gọi là. – Kyslik