title: rename all the files in a folder
body: <p>i have been trying to rename all the files (images) in a folder on my website but it does not work. the files are not renamed.</p>
  
  <p>i have an input field for 'name' i want to use that name, add a uniqid and rename all the files.
  here's the code that i am using:</p>
  
  <pre><code>&lt;?php
  if(isset($_POST['submit2'])){
  $name = $_POST['name'];
  $directory = glob("../basic_images/*.*");
  {
  if ($file != "." &amp;&amp; $file != "..") {
  
      $newName = uniqid().$name;
  
      rename($directory.$file, $directory.$newName);
  }}}
  ?&gt;
  </code></pre>
  
  <p>besides, do i really need to _Post the $name variable?</p>
  
  <p>P.S. i want to rename all the files and then copy them to another folder.</p>