title: how to search for a file with php
body: <p>First thing is first. I am not a php developer this is something that is needed for my job so I took it on and I am learning as i go</p>
  
  <p>Right now we have an excel sheet that holds links for a manuals for the items we make and these have to be updated manually. It can take hours to do. so I am trying to find a way to do this to cut the time.</p>
  
  <p>I can read the excel file to get the info I need using javascript and then I send that to php with an ajax call.</p>
  
  <p>I have made sure I get the data I need and make it look how they do on the server.</p>
  
  <p>I have been googling all day trying to get it to work but I just keep coming up empty. </p>
  
  <p>Here is my code in the php file.</p>
  
  <pre><code>    &lt;?php
  $search = isset($_POST['urlData']) ? rawurldecode($_POST['urlData']) : "Nope Still not set";
  $path = $_SERVER['DOCUMENT_ROOT'];
  
  
  $it = new RecursiveDirectoryIterator( $path );
  foreach (new RecursiveIteratorIterator($it) as $file){
      $pathfile = str_replace($path,'',$file);
      if (strpos($pathfile, $search) !== false) {
          echo " pathFile var =&gt; ". $pathfile . "| Search var =&gt; " . $search;
          $encodedUrl = rawurlencode($pathfile .$search);
          echo 'link = http://manuals.myCompany.com/'. $doneUrl .'&lt;br&gt;';
  
      }else{
  
          echo "File does not exist =&gt; ";
          echo $path. "&lt;= Path " . $search."&lt;= Search ". $pathfile . "&lt;= Pathfile";
  
      }
      break;
  }
  </code></pre>
  
  <p>So I need to give the php file the name of a manual and see if it is in the directory somewhere.</p>
  
  <p>this file is searchManuals.php stored in the manuals folder (manuals/searchManuals.php).The files I look for are in folders in the same directory with it (manuals/english/jdv0/pdf/manual.pdf).</p>