【问题标题】:cannot get post data from a file input无法从文件输入中获取发布数据
【发布时间】:2018-12-31 14:10:53
【问题描述】:

我不知道为什么这不起作用...帖子中不包含任何数据... 所以在使用 php 中的设置之类的设置之前,我还应该考虑其他什么?

<html lang="en">
    <body>
    <form method="post" action="gambaqprocess.php" enctype="multipart/form-data">
    <div class="form-group">
                            <label>file attachment</label> 
                                    <input type="file" name="file" id="file"
                            cols="10" wrap="soft" placeholder="" rows="5" value=""></input>
                            </div>


                            <button type="submit" class="btn btn-danger" name="action"
                                value="view">Add</button>
                                </form>
                                    </body>
                                </html>

那么这就是过程

<?php

if(isset($_POST['file']))
{
    $file=$_files['file'];
    print_r($file);
    $filename=$_files['file']['name'];
    print_r($file);

}else
    echo'cannot get post data';

?>

【问题讨论】:

    标签: javascript php oracle


    【解决方案1】:

    这里只有文件元素在表单中,这就是$_POST 不会包含任何数据的原因。可以从$_FILES 变量中检索以表格形式发布的文件。所以你应该尝试:

    if(isset($_FILES['file']))
    

    代替

    if(isset($_POST['file']))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-20
      • 1970-01-01
      • 2017-04-26
      • 2019-08-11
      • 1970-01-01
      • 1970-01-01
      • 2016-02-08
      • 2016-04-17
      相关资源
      最近更新 更多