简体   繁体   中英

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; 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):

<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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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