【问题标题】:POST method not taking file inputsPOST 方法不接受文件输入
【发布时间】:2016-02-15 19:36:12
【问题描述】:

这是我的 HTML:

<!DOCTYPE html>
<html>
<head>
    <title>This is where we add Party.</title>
</head>
<body>
<form action="viewParties.php" method="post" enctype="multipart/form-data">

PartyList:<br>
<input type="text" name="partylist"><br>
<input type="file" name="pafile"><br><br>

President:<br>
<input type="text" name="president"><br>
<input type="file" name="pfile"><br><br>

Vice President:<br>
<input type="text" name="vicepresident"><br>
<input type="file" name="vpfile"><br><br>

Secretary:<br>
<input type="text" name="secretary"><br>
<input type="file" name="secpfile"><br><br>

<input type="submit" name="submit"><br><br>

</form> 
</body>
</html>

基本上,我想要让 POST 方法同时获取名称和文件位置。但是当我在另一个 PHP 文件中 print_r($_POST) 时,它只显示名称。有谁知道如何解决这个问题?

【问题讨论】:

  • 使用 print_r($_FILES);用于打印文件值
  • 这样写enctype="multipart/form-data"
  • 嗯。 =) 有点晚了,但谢谢你/ =D

标签: php file post methods


【解决方案1】:

找到了。事实证明,我不仅需要 print($_POST) 来查看我提交的内容,而且还需要 print_r($_FILES) 来查看我提交的文件。我做了一些修补,这就是我发现的。希望这对其他人有帮助。 =)

【讨论】:

    猜你喜欢
    • 2021-08-20
    • 2014-09-10
    • 2013-10-21
    • 1970-01-01
    • 2014-05-04
    • 1970-01-01
    • 1970-01-01
    • 2015-01-08
    • 1970-01-01
    相关资源
    最近更新 更多