title: How to list all files in a folder using PHP/jQuery
body: <h2>Context</h2>
  
  <p>Hello, I would like to list all files in a folder, so I first thought about doing it in <strong>php</strong> by using the PHP <code>scandir()</code> Function, which resulted in something like that:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  $dir = "/images/";
  
  // Sort in ascending order - this is default
  $a = scandir($dir);
  
  // Sort in descending order
  $b = scandir($dir,1);
  
  print_r($a);
  print_r($b);
  ?&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Result:</p>
  
  <blockquote>
  <pre><code>Array
  (
  [0] =&gt; .
  [1] =&gt; ..
  [2] =&gt; film1.mkv
  [3] =&gt; film2.mkv
  [4] =&gt; film3.mkv
  [5] =&gt; film4.mkv
  )
  Array
  (
  [0] =&gt; film4.mkv
  [1] =&gt; film3.mkv
  [2] =&gt; film2.mkv
  [3] =&gt; film1.mkv
  [4] =&gt; ..
  [5] =&gt; .
  )
  </code></pre>
  </blockquote>
  
  <p>But then I realised, as I wanna scan all videos inside my folder in order to display them and give the choice to the local user to clic on any of them; using <strong>JavaScript</strong> could be a good idea.</p>
  
  <h2>Question</h2>
  
  <p>Is it possible to do it in Javascript ? Is it a good Idea to use it instead of php ?</p>
  
  <p><strong>EDIT:</strong> The final purpose of this is to launch a movie, exactly like Netflix or all famous movies-related websites are doing</p>