Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/283.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/6/codeigniter/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 在codeigniter中同时上载多个文件时,如何检查文件是否为空?_Php_Codeigniter - Fatal编程技术网

Php 在codeigniter中同时上载多个文件时,如何检查文件是否为空?

Php 在codeigniter中同时上载多个文件时,如何检查文件是否为空?,php,codeigniter,Php,Codeigniter,在codeigniter中同时上载多个文件时,如何检查文件是否为空 <input type="file" name = "user_file[]" multiple /> <input type="file" name = "user_file[]" multiple /> 控制器代码: if (empty($_FILES['user_file']['name'])) { echo'<script>alert("please upload a

在codeigniter中同时上载多个文件时,如何检查文件是否为空

<input type="file" name = "user_file[]"  multiple />
<input type="file" name = "user_file[]"  multiple />

控制器代码:

if (empty($_FILES['user_file']['name'])) {

   echo'<script>alert("please upload a file or write something")</script>';
   exit();
}
if(空($\u文件['user\u文件]['name'])){
echo'alert(“请上传文件或写东西”);
退出();
}
但它不工作,空文件也上传??请任何人为此提供解决方案…

您可以使用

if (filesize($file_path) == 0){
    echo "The file is empty";
}
或者也试试看

if (trim(file_get_contents($file_path)) == false) {
     echo "The file is empty";
}
试试这个

if ($_FILES["fileToUpload"]["size"] == 0) {
    echo "Sorry, your file is empty.";
}