我正在尝试验证文件上传以进行图像上传,但它没有像其他字段那样获得验证.我正在使用Form_Validation.php流程进行验证.
图片上传阵列:
array(
'field'=>'image',
'label' => 'Image',
'rules' => 'required'
)
Run Code Online (Sandbox Code Playgroud)
当我尝试上传图片时,它没有响应,就像它是必需的等等.我也想验证它.jpg等"和如何设置文件值在不正确的文件上,而不是.jpg我们尝试上传.pdf"像我们设置的值输入字段set_value('field name')等
我检查了很多问题,并尝试使用调用方法,但无法修复它.
更新:
请通过代码示例提供详细答案.请在示例中使用form_validation.php方式,并提供回调示例代码,以便我可以相应地阅读/学习和修改它.
更新2:
public function Task()
{
if ($this->form_validation->run('Sub_Admin/task') == FALSE) {
$this->data['Task'] = $this->bm->get_usr();
$data['title'] = "Add New Task";
$this->load->view('Subadmin/header',$data);
$this->load->view('Subadmin/nav');
$this->load->view('Subadmin/sidebar');
$this->load->view('Subadmin/task', $this->data);
$this->load->view('Subadmin/footer');
}
else
{
$config['upload_path'] = './taskimages/'; //The path where the image will be save
$config['allowed_types'] = 'gif|jpg|png'; //Images extensions accepted
$config['max_size'] ='10048'; //The max size of the image in kb's …Run Code Online (Sandbox Code Playgroud) 我想应用class上的HTML标签,如果标签存在.
我试过这段代码:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>index</title>
<style>
.black
{
background:#000;
color:white;
}
</style>
<script type="text/javascript">
$(window).load(function () {
$('textarea').addClass('black');
});
</script>
</head>
<body>
<div>
<textarea>content</textarea>
</div>
<script src="jquery.js"></script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我想要的:如果HTML正文包含textarea标记,那么.black该类将自动应用它.