title: How can i rename multiple files on upload
body: <p>I am facing a small issue here. I have the following form which I use to allow users to upload one or more files:</p>
  <pre><code>&lt;form action=&quot;RejoinReq.php&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot;&gt;
      Attachment 1: &lt;input type=&quot;file&quot; name=&quot;file[]&quot; id=&quot;file&quot; maxlength=&quot;500&quot; accept=&quot;application/pdf,image/*&quot; /&gt;
      &lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Request&quot; /&gt;
  &lt;/form&gt;
  </code></pre>
  <p>Next, I need to rename the file(s) before saving them to the server. For that I am trying to use:</p>
  <p><strong>RejoinReq.php</strong></p>
  <pre><code>&lt;?php
  
  function findexts ($filename) {
      $filename = strtolower($filename);
      $exts = explode(&quot;.&quot;, $_FILES[&quot;file&quot;][&quot;name&quot;]);
      $n = count($exts) - 1;
      $exts = $exts[$n];
      return $exts;
  }
  $ext = findexts($_FILES['file']['name']);
  $target = &quot;upload/&quot;;
  $target = $target . $_SESSION['myusername'] . &quot;Rejoin.&quot; . $ext;
  if (file_exists(&quot;upload/&quot; . $_FILES[&quot;file&quot;][&quot;name&quot;])) {
      //echo $_FILES[&quot;file&quot;][&quot;name&quot;] . &quot; already exists. &quot;;
  }
  else {
      move_uploaded_file($_FILES[&quot;file&quot;][&quot;tmp_name&quot;],$target);
      //echo &quot;Stored in: &quot; . &quot;upload/&quot; . $_FILES[&quot;file&quot;][&quot;name&quot;];
  }
  </code></pre>
  <p><strong>Updated - Modification on PHP code</strong></p>
  <blockquote>
  <p><em>Warning: <code>findexts()</code> expects parameter 1 to be string, array given</em></p>
  <p><em>Warning: <code>move_uploaded_file()</code> expects parameter 1 to be string, array given</em></p>
  </blockquote>