doupo2157 2017-07-13 05:58
浏览 112
已采纳

HTML表单文件上传不起作用,$ _POST不转发数据

Maybe it is just too early here, but can't figure out the problem... I have made several forms already, but this time for a reason I can't forward the data of my file input.

Here is my index.php (where the form is):

<form action="confirm.php" method="post" enctype="multipart/form-data">
<input type="file" name="file1">
<input type="submit" name="order">
</form>

Here is my confirm.php:

<?php
if (isset($_POST['order'])) {

    $file       = $_POST['file1'];

    echo $file;

}
?>

And I get the following error message:

Notice: Undefined index: file1 in /Applications/MAMP/htdocs/.../confirm.php on line 4

I seriously don't understand what is the problem. This is a rock easy form and I think it is correct. Can you please help me with this huge issue? :DD Btw. the form proceeds all the other input data except the file.

Thanks, Matthew

  • 写回答

3条回答 默认 最新

  • dqtok88424 2017-07-13 06:03
    关注

    Since your input type is file so you can not access by $_POST

    `type="file"` // Not Accessible through `$_POST` 
    

    Php is providing separate http group $_FILES for getting the value of input which type should be file like this type="file"

    So you can you get the input value by $_FILES

    if(isset($_POST['order'])){
       $Input_File = $_FILES['file1'];
       $Input_File_Name = $Input_File['name'];
       $Input_File_type = $Input_File['type'];
       $Input_File_tmp_name = $Input_File['tmp_name'];
       $Input_File_size = $Input_File['size'];
    
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分