2

PHP script

   $count = 0;
    foreach ($_FILES['filesToUpload'] as $file) {
      //upload process
      echo $file[$count]['tmp_name'].',';
      $count ++;
    }

HTML

<form method="POST" action="action-here" enctype="multipart/form-data">
<input class="btn" name="filesToUpload[]" type="file" multiple="" />
<input class="btn primary" type="submit" value="Submit">
</form>

I'm doing this majorly wrong. What i'm trying to do is make it so you select the files then the php script processes it like an array?

I keep getting out puts such as 1,i,C,,,.

I know other ways to do multiple uploads, but I know this is one of the simplest.

2 Answers 2

3
foreach ($_FILES['filesToUpload']['error'] as $k => $error) {
  echo $_FILES['filesToUpload']['tmp_name'][$k].',';
}

Tips: debug it with print_r($_FILES).

Sign up to request clarification or add additional context in comments.

1 Comment

I want to make it simple with $file['tmp_name'][$k], but it turns out that the only way is $_FILES['filesToUpload']['tmp_name'][$k].
0

you should write it this way:

echo $file['tmp_name'][$count].',';

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.