dongxiao3694 2015-01-13 19:07
浏览 18
已采纳

未定义索引:第12,15,16,17,18,19,20行中的文件

I get errors in this part to upload a file image into a folder an after that save in database, help me please

  11   $allowedExts = array("gif", "jpeg", "jpg", "png");
  12   $temp = explode(".", $_FILES["file"]["name"]);
  13   $extension = end($temp);
  14
  15   if ((($_FILES["file"]["type"] == "image/gif")
  16   || ($_FILES["file"]["type"] == "image/jpeg")
  17   || ($_FILES["file"]["type"] == "image/jpg")
  18   || ($_FILES["file"]["type"] == "image/pjpeg")
  19   || ($_FILES["file"]["type"] == "image/x-png")
  20   || ($_FILES["file"]["type"] == "image/png"))
       && ($_FILES["file"]["size"] < 100000)
       && in_array($extension, $allowedExts)) {
       if ($_FILES["file"]["error"] > 0) {
       echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
      } else {
      if (file_exists("../img/propieties/" . $_FILES["file"]["name"])) {
        echo $_FILES["file"]["name"] . " already exists. ";
      } else {
        move_uploaded_file($_FILES["file"]["tmp_name"],
        "../img/propieties/" . $_FILES["file"]["name"]);
      }
      }
      } else {
       echo "Invalid file";
      }

I got a element input normal into a form with method POST

<input type="file" name="file" id="file">
  • 写回答

1条回答 默认 最新

  • duandui2803 2015-01-13 19:12
    关注

    You're probably missing your enctype="multipart/form-data" attribute in your <form> tag. Without it the file will not upload.

    <form enctype="multipart/form-data" action="" method="post">
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

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