title: Ajax / php folder listing
body: <p>i have a strange problem with the listing of a intranet directory, i searched on google and stackoverflow some notice but without luck.</p>
  
  <p>This is the very simple ajax call:</p>
  
  <pre><code>function mostra_cartella() {
  $.ajax({
      url:'risorse/leggi_directory.php',
      data: { cliente: document.getElementById("cliente").value,
              codice : document.getElementById("codice").value,
              root   : "/Archivio CAD-CAM/"
            },
      dataType:"html",
      cache:false,
      }).done(function(html) {
          $("#cartella_file").html(html);
      });
  
  }
  </code></pre>
  
  <p>and this is the php file return me the folders list:</p>
  
  <pre><code>header('Content-Type: text/html');
  
  $host = $_SERVER['HTTP_HOST'];
  $codice = $_GET['codice'];
  $cliente = $_GET['cliente'];
  $root = $_GET['root'];
  
  $path = "//".$host.$root.$cliente."/".$codice."&lt;/br&gt;";
  echo $path;
  
  $path2 = "//192.168.0.10/Archivio CAD-CAM/GD/";
  echo $path2;
  
  
  
      echo "&lt;div id='listato'&gt;";
      echo "&lt;ul id='multi'&gt;";
      if($handler = opendir($path)){
       while(($file = readdir($handler)) !== false) {
        if ($file != "." &amp;&amp; $file != "..") {
              echo "&lt;li&gt;".$file."&lt;/li&gt;";
        }
          }
      }
          else {
           echo "La directory non è stata trovata o risulta vuota";
          }
  
      closedir($handler);
      echo "&lt;/div&gt;";
      echo "&lt;/ul&gt;";
  
  ?&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The problem is that:the result of variable $path and $path2 is the same EVER (it's for my test) and the php page is called EVER from the ajax call.</p>
  
  <p>First attempt:</p>
  
  <p>if use the $path2 variable to create the handler,and not with the data pass with ajax,everything works fine,because the path is already in php file? (do not know)</p>
  
  <p>second attempt:</p>
  
  <p>if i use variable $path (same url of $path2),composed by data fropm ajax call,don't return me anything,and opendir() fail to create handler and give me the error:</p>
  
  <p><strong>Warning: opendir(//192.168.0.10/Archivio CAD-CAM/GD/&lt;/br&gt;,//192.168.0.10/Archivio CAD-CAM/GD/&lt;/br&gt;): in C:\wamp\www\Gestionale Programmi\risorse\leggi_directory.php on line 46</strong></p>
  
  <p>What is the difference between the two methods?</p>
  
  <p>Why one work and the other not even though the variables $path and $path2 have the same result?</p>
  
  <p>Thanks in advance for any help</p>