简体   繁体   English

从$ _FILES存储的php数组

[英]php array storing from $_FILES

Hello I have a stupid problem I want to upload a file to a server. 您好我有一个愚蠢的问题我想将文件上传到服务器。 The process works but I have multiple file input fields and I want to store their names inside of an array and that doesn't work -_-: 该过程有效,但我有多个文件输入字段,我想将它们的名称存储在一个数组中,这不起作用-_-:

  $target_dir = "../steppys/" . $id;
  $target_files = array();
  $target_files[] = $target_dir . basename($_FILES["image1"]["name"]);
  echo $target_files[0];

Thats the code and it will echo 0; 这是代码,它将回显0; BUT when this: 但是这个时候:

$target_dir = "../steppys/" . $id;
echo $target_dir . basename($_FILES["image1"]["name"]);

It give me the path name. 它给我路径名称。 And I need to add this to an array. 我需要将其添加到数组中。 Array are also working fine I have tested them(also dynamically adding things). 数组也工作正常我测试了它们(也动态添加东西)。

Htmlcode(simple form but also tested): Htmlcode(简单形式但也经过测试):

<form enctype="multipart/form-data" action="test.php" method="post">
      <div class="form-group">
        <input class="form-control" type="file" name="image1" />
      </div>
      <input class="form-control" type="submit">
    </form>

Thanks in advance 提前致谢

是的我解决了我没有上传一个文件的问题......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM