title: How to Display all videos in a folder
body: <p>i am scripting the code where you know i can list all the video files of a specific folder to get listed in webpage.. but somehow i am not able to get the output of the same so request you all guys if anyone can help in this matter... below listed is the code with the output snap.</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  &lt;?php
  
  $dir = "videos/";
  $videoW = 320;
  $videoH = 240;
  
  if (is_dir($dir))
  {
      if ($dh = opendir($dir)){
  
          while (($file = readdir($dh)) !== false){
  
              if($file != '.' &amp;&amp; $file != '..'){
  
                  echo 
                  "
                      &lt;div style='display: block'&gt;
                          &lt;video width=\"$videoW\" height=\"$videoH\" controls&gt;
                            &lt;source src=\"". $dir . $file ."\" type=\"video/mp4\"&gt;
                            &lt;source src=\"". $dir . $file ."\" type=\"video/ogg\"&gt;
                          &lt;/video&gt;
                      &lt;/div&gt;
                  ";
  
              }
  
          }
  
          closedir($dh);
  
        }
  }
  ?&gt;
  </code></pre>
  
  <p>
  </p>
  
  <p>i am using windows 10 (64 bit).. i don't know anyhow this code is not working for me.</p>
  
  <p><img src="https://i.stack.imgur.com/UGQna.jpg" alt="webpage output snap"></p>
  
  <p>it would be really helpful if anyone can help me on this.</p>