php - 多文件输入和表单验证?
问题描述
我的表单中有多个文件和输入文本。我的代码是:
if(formValidationIsGood) {
if(customeCheckFileErrorIsEmpty) {
//StartProcess
}
else {
//I load my view with my array which contains the different error related to the files.
}
else {
//I load my view with the form error (set up by : $this->form_validation->set_rules('variable', 'Variable', 'required');) But if there is an error for the files I cant display it.
}
使用此代码,我无法同时显示表单错误和文件错误。例如,用户正在上传 csv 文件而不是 pdf 文件,并且他忘记写入文本输入,将显示表单错误但不会显示文件错误,反之亦然。
显然我正在使用代码点火器提供的帮助文件。
解决方案
由于您想显示 A 或 B 的错误消息,您可以试试这个:
if (!formValidationIsGood || !customeCheckFileErrorIsEmpty)
{
// load the view and display whatever errors you found
}
else
{
// form validation IS good and the files error is empty
}
上面的if
子句将评估true
是否formValidationIsGood
ISN'T true
(!
前缀是关键)或customeCheckFileErrorIsEmpty
ISN't true
(这意味着存在错误)
推荐阅读
- google-apps-script - 从一个工作表复制查询函数的结果,并将其附加到不同文件中另一个工作表的末尾
- python - 使用网格评估数据
- node.js - GCP 构建失败 gyp ERR!堆栈错误:`make` 失败,退出代码:2
- excel - 如果列表的所有值都存在于不同的列中,请更改excel中单元格的颜色?
- oracle - 如何将 SQL 语句的结果保存到变量中?
- xml - 如何在包含 xml 的 Oracle 数据库查询字符串中发送与号
- javascript - 如何在引导模式窗口打开时授予用户访问权限
- firebase - Firestore:合并 2 个流并发出两个值
- angular - @angular/cdk/collections DataSource 的断开方法
没有被调用 - excel - 如何将键盘快捷键添加到已经自由编码的 VBA 模块?