Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/251.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 仅当所有内容都为真或一个文件错误时,上传文件ok,如果其中一个文件为空,则使用codeigniter 4这是错误的_Php_Codeigniter 4 - Fatal编程技术网

Php 仅当所有内容都为真或一个文件错误时,上传文件ok,如果其中一个文件为空,则使用codeigniter 4这是错误的

Php 仅当所有内容都为真或一个文件错误时,上传文件ok,如果其中一个文件为空,则使用codeigniter 4这是错误的,php,codeigniter-4,Php,Codeigniter 4,我是codeigniter 4的新手,我有两个输入文件,它们在数据库中可以为null,如果它们为true,则我的控制器选择image,我的代码为罚款,如果其中一个不是image,则我的代码为罚款,但如果其中一个为空,则我的代码为错,两个验证都已检查,例如,如果profile be selected image和TestImage not selected,结果说测试和死亡。请帮忙!多谢各位 我认为: <section class="col-12 col-lg-4">

我是codeigniter 4的新手,我有两个输入文件,它们在数据库中可以为null,如果它们为true,则我的控制器选择image,我的代码为罚款,如果其中一个不是image,则我的代码为罚款,但如果其中一个为空,则我的代码为错,两个验证都已检查,例如,如果profile be selected image和TestImage not selected,结果说测试和死亡。请帮忙!多谢各位

我认为:

<section class="col-12 col-lg-4">
  <label for="ProfileUrl">Profile Image</label>
    <input type="file" name="ProfileUrl" id="ProfileUrl" placeholder="choose your image"
      class="form-control bg-input border-boot rounded-5"/>
         <?php if ($validation->getError('ProfileUrl')): ?>
            <div class='alert alert-danger mt-2'>
                <?= $error = $validation->getError('ProfileUrl'); ?>
            </div>
         <?php endif; ?>
</section>
<section class="col-12 col-lg-4">
  <label for="TestImage">test Image</label>
    <input type="file" name="TestImage" id="TestImage" placeholder="choose your image"
    class="form-control bg-input border-boot rounded-5"/>
</section>

谢谢

我找到了解决办法

$ImageFile_1 = $this->request->getFile('ProfileUrl');

            if ($ImageFile_1 && $ImageFile_1->getSize()>1)

如果我检查每个文件大小超过1字节。

编辑:等待。。。我现在看到了“如果”。。混合使用这两种符号有什么原因吗-有一个独立的“endif;”,没有“if”,例如代码片段不完整。-此外,“代码错误”也没有多大帮助。。你对“错”或“对”的定义是什么?谢谢,如果第一个文件选择,第二个是空的,第一个和第二个函数工作,我想如果文件选择在它们中的每一个都工作@LarsStegelitzRemove“die()”。。。你们知道这是在做什么,是吗?是的,我知道,我在测试中添加了“die()”,并且在我问问题和同样的问题之前删除了它;:)@Larsstegelitz您是说TestImage缺少验证失败消息吗?没有相应HTML块的那个?
$ImageFile_1 = $this->request->getFile('ProfileUrl');

            if ($ImageFile_1 && $ImageFile_1->getSize()>1)