也許我缺少一些簡單的東西,但我似乎無法讓我的表單驗證恰到好處。CodeIgniter - 驗證帶有字段和文件上傳的表單
我怎樣才能獲得表單驗證檢查文件校驗也沒有做一個
$this->upload->do_upload("fldImage")
這是我目前正在覈查過程:
if ($this->form_validation->run() == FALSE)
{
if (! $this->upload->display_errors("fldImage"))
{
$error = array('error' => $this->upload->display_errors());
}
$this->load->view('submitBlog', $error);
}
else
{
if (! $this->upload->do_upload("fldImage"))
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('submitBlog', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
unset($blog['submit']);
$imagePath = "uploads/".$data['upload_data']['file_name'];
$blog['fldImage'] = $imagePath;
$blog['fldDateAdded'] = $datetime;
$this->db->insert('tblBlog', $blog);
$this->load->view('submitBlogSuccess', $data);
}
}
但我當然不能打電話
do_upload("fldImage")
沒有運行
do_upload()
但如果圖像有效但其他表單值不是,我不想上傳圖像。