Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/243.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 如果上载了文件,则返回多个隐藏字段中的$\u POST_Php - Fatal编程技术网

Php 如果上载了文件,则返回多个隐藏字段中的$\u POST

Php 如果上载了文件,则返回多个隐藏字段中的$\u POST,php,Php,格雷赫特:Prijs:Plaatje:上传: 你有 if(isset($_POST['submit'])) { if((array_search('', $_POST["gerecht"])!==false) or (array_search('', $_POST["prijs"])!==false)) { //1 or more field empty echo "<span class=\"error\">Please fill in all fi

格雷赫特:

Prijs:

Plaatje:

上传:

你有

if(isset($_POST['submit'])) {
        if((array_search('', $_POST["gerecht"])!==false) or (array_search('', $_POST["prijs"])!==false)) { //1 or more field empty
        echo "<span class=\"error\">Please fill in all fields</span>";
        exit();
    }else{//field filled in



       foreach ($_FILES['file']['name'] as $i => $name) {

            if ($_FILES['file']['error'][$i] == 4) { // no upload continue
                continue;
            }
            if ($_FILES['file']['error'][$i] == 0) {

                echo $_POST['id'];


            }//end else error 0

       }//end foreach 
    }//end filled in forms

}else{ //submit button clicked


}

等等

您将只得到数字5,因为它是最后一个,并且正在覆盖它之前的一个

与输入文本相同,
name
属性应该不同


执行
var\u转储($\u POST)
查看所有正在发布的内容。

如果重复使用表单元素名称(而不是数组),最后一个值将覆盖以前的值。看看你是怎么做到的

<input type="hidden" value="1" name="id">
<input type="hidden" value="2" name="id">

试试看

<input type="hidden" value="5" name="id">

并对它们进行迭代

<input type="hidden" value="1" name="id">
<input type="hidden" value="2" name="id">
<input type="hidden" value="5" name="id">
<input type="hidden" value="5" name="id[]">