我有一些用于图像上传的脚本,我将它与表单验证一起使用。所以这是代码:
$this->form_validation->set_rules('name','Name','required|max_length[30]|xss_clean');
$this->form_validation->set_rules('desc','Description','required|xss_clean');
if ($this->form_validation->run() == TRUE)
{
$config = array(
'allowed_types' => 'jpg|jpeg|png|gif',
'upload_path' => path/to/folder,
'max_size' => 3000,
'max_height' => 1024,
'max_width' => 1024,
'remove_spaces' => TRUE
);
$this->load->library('upload', $config);
if ($this->upload->do_upload())
{
//code for insert this data into database
}
else
{
//code for FALSE the form validation and error message with flashdata
}
现在,如果图像上传出现错误,我想伪造表格。我想像某些字段的错误(如果它是空的)一样这样做,以获取帖子变量的数据(对于字段的内容)。
最好的方法是什么?