为什么我仍然看到第13行(“文件”)的未定义索引错误?

时间:2019-02-10 20:05:20

标签: indexing

我正在尝试使用php创建一个简单的拖放页面。当我单击“提交”按钮时,出现错误:注意:未定义的索引:第13行的C:\ xampp \ htdocs \ phpfiles \ DragAndDrop \ includes \ gallery-upload.inc.php中的文件来自htmlphp的“文件”索引?

这是HTML和PHP代码:

enter code here
 <!--continuted from HTML page-->
    </section>
<?php
  $_SESSION['username'] = "Admin";
  if (isset($_SESSION['username'])) {
  echo '<div class="gallery-upload">
  <form action="includes/gallery-upload.inc.php" method="post" enctype="mutipart/form-data">
    <input type="text" name="filename" placeholder="File Name...">
    <input type="text" name="filetitle" placeholder="Image Title...">
    <input type="text" name="filedesc" placeholder="Image description...">
    <input type="file" name="file">
    <button type="submit" name="submit">Upload</button>
    </form>
    </div>';
      }
  ?>
</main>
</body>
</html>

<!--and the php page-->
<?php

    if (isset($_POST['submit'])) {//checks submit form and posts the info

    $newFileName = $_POST['filename'];
    if (empty($_POST['filename'])) { //if filename is emptly
        $newFileName = "gallery"; //if filename is empty, generates name
          } else {
              $newFileName = strtolower(str_replace(" ", "-", $newFileName));  //if spaces are in the name, creates stringholder
            }
          $imageTitle = $_POST['filetitle'];
          $imageDesc = $_POST['filedesc'];
          $file = $_FILES['file'];
    }
?>

1 个答案:

答案 0 :(得分:0)

您有错字:

share_context

应该是

mutipart/form-data