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">
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容