[英]Image Type Validation in codeigniter
I am new to Codeigniter. 我是Codeigniter的新手。 Working on an form validation having image in the form.
进行表单验证并在表单中包含图像。 Using Module MVC extension in CodeIgniter.
在CodeIgniter中使用Module MVC扩展。
//for upooading image I found this file upload snippet //对于更新图片,我发现了此文件上传代码段
$config['upload_path'] = './uploads/audio_files/';
$config['allowed_types'] = 'gif|jpg|jpeg|png';
$config['max_size'] = '2048';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload($file_name))
{
$error = array('error' => $this->upload->display_errors());
$file1 = '';
}
else
{
$upload_data = $this->upload->data();
$file1 = $upload_data['file_name'];
}
This is working fine. 一切正常。 File which is not jpeg |
不是jpeg的文件| gif is not uploaded.
gif未上传。 but user dont get any error message.
但用户未收到任何错误消息。 I want the user to show that particular error when other image type is uploaded.
我希望用户在上传其他图像类型时显示该特定错误。 Please help
请帮忙
I tried this but failed. 我试过了但是失败了。
try 1 : $this->template->load_partial('admin/admin_master', 'admin/form', $error);
try 2. : loading view with $error
Thanks 谢谢
Can't you associate a view with an error message? 您无法将视图与错误消息相关联吗? For instance:
例如:
After 后
$file1 = '';
You put: 你把:
$this->load->view('error_view', $error, $file1);
You would have to make a separate view page called 'error_view.php'. 您将必须创建一个单独的视图页面,称为“ error_view.php”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.