PHP POST数据未通过enctype =" multipart / form-data"

时间:2014-09-03 02:19:14

标签: php

我无法让我的表单发布数据。正如此代码所示,文件已上传,但我没有其他表单字段的任何发布数据。我注意到,如果我摆脱multipart / form-data enctype,它将不会上传(显然),但我确实得到了其他字段的帖子数据。关于这是为什么的任何想法?

此代码出现的页面是index.php?page = page1& upload = 1

<form enctype="multipart/form-data" action="?page=page1&upload=2" method="post">
Select Location: <select name="location">
    <option>Select Location</option>
    <option value="N">North</option>
    <option value="S">South</option>
    <option value="E">East</option>
    <option value="W">West</option>
</select><br />
Upload File: <input name="ufile" type="file" id="ufile" size="50" /><br />
<b><u>Sunday</u></b> Date: <select name="month">
    <option> - Month - </option>
    <option value="01">January</option>
    <option value="02">Febuary</option>
    <option value="03">March</option>
    <option value="04">April</option>
    <option value="05">May</option>
    <option value="06">June</option>
    <option value="07">July</option>
    <option value="08">August</option>
    <option value="09">September</option>
    <option value="10">October</option>
    <option value="11">November</option>
    <option value="12">December</option>
</select>

<select name="day">
    <option> - Day - </option>
    <option value="01">1</option>
    <option value="02">2</option>
    <option value="03">3</option>
    <option value="04">4</option>
    <option value="05">5</option>
    <option value="06">6</option>
    <option value="07">7</option>
    <option value="08">8</option>
    <option value="09">9</option>
    <option value="10">10</option>
    <option value="11">11</option>
    <option value="12">12</option>
    <option value="13">13</option>
    <option value="14">14</option>
    <option value="15">15</option>
    <option value="16">16</option>
    <option value="17">17</option>
    <option value="18">18</option>
    <option value="19">19</option>
    <option value="20">20</option>
    <option value="21">21</option>
    <option value="22">22</option>
    <option value="23">23</option>
    <option value="24">24</option>
    <option value="25">25</option>
    <option value="26">26</option>
    <option value="27">27</option>
    <option value="28">28</option>
    <option value="29">29</option>
    <option value="30">30</option>
    <option value="31">31</option>
</select>
<select name="year">
<?php
    $optionyear = date("Y",time());
    $currentyear = $optionyear;
    while($optionyear != 1990) {
        echo "<option value=\"".$optionyear."\"";
        if($optionyear == $currentyear) {
            echo " selected";
        }
        echo ">".$optionyear."</option>";
        $optionyear--;
    }
?>
</select><br />
<input type="submit" name="Submit" value="Upload" /><br />
</form>

谢谢!

1 个答案:

答案 0 :(得分:0)

您可以使用$_FILES[]获取上传数据,使用$_POST[]

获取其他数据

尝试

echo "<pre>";
print_r($_POST);
print_r($_FILES['ufile']);
echo "</pre>";

顺便说一下,<form>元素的关闭标记在哪里?