title: Invalid argument supplied for foreach() in multiple images uploading
body: <p>I am trying to upload multiple image files and rename them as user supplied name. After receiving the POST parameters(like filename, department_id etc.).</p>
  
  <p>But the following code gives me a warning "Warning: Invalid argument supplied for foreach() in line 11", which is the foreach() containing line. Any possible error source ? Any help would be appreciated!</p>
  
  <pre><code>&lt;?php
      include_once './classes/functions.php';
      if (isset($_POST['sendfiles'])) {
              $filename = $_POST['filename'];
              $department_id = $_POST['department_id'];
              $reg_no = $_POST['reg_no'];
              $fiscal_year = $_POST['fiscal_year'];
              $tags = $_POST['tags'];
              $fileName_array = "";
              $new_file_id = get_new_id('files');
               foreach ($_FILES['photos']['name'] as $name =&gt; $value) {
                  $filename = stripslashes($_FILES['photos']['name'][$name]);
                  //get the extension of the file in a lower case format
                  $extension = getExtension($filename);
                  $extension = strtolower($extension);
      //            echo "\n This is the extension: ", $extension;
                  if (($extension != "jpg") &amp;&amp; ($extension != "jpeg") &amp;&amp; ($extension != "png") &amp;&amp; ($extension != "gif")) {
  
                      header("Location:../add_new_file.php?msg=error_file_type");
      //                $errors = 1;
                  } else {
                      $size = filesize($_FILES['photos']['tmp_name'][$name]);
                      if ($size &gt; 5000 * 1024) {
                          header("Location:../add_new_file.php?msg=error_file_size");
      //                    $errors = 1;
                      }
                      $image_name = $filename . '.' . $extension;
                      $newname = 'department_' . $department_id . '/' . $new_file_id . '_' . $image_name;
      //                $new_file_id++;
                      $fileName_array += $newname . ',';
                      $copied = copy($_FILES['photos']['tmp_name'][$name], $newname);
                      if (!$copied) {
                          header('Location: ../add_new_file.php?msg=error_upload_file');
                      }
                  }
              }
      //        if (add_new_file($filename, $department_id, $reg_no, $fiscal_year, $tags, $fileName_array) == true) {
      //            return true;
      //        }
      //        return false;
          }
      ?&gt;
  </code></pre>