Create clickable links of local files using exec() command?
<p>I am a beginner to PHP so please forgive any ignorance...</p>

<p>I am using the exec() command as following to get the list of files in my media directory..</p>

<pre><code>&lt;?php // exec.php
$cmd = "dir";   // Windows
exec(escapeshellcmd($cmd), $output, $status);
if ($status) echo "Exec command failed";
else
{
echo "&lt;pre&gt;";
foreach($output as $line) echo "&lt;a href='$line'&gt;$line&lt;/a&gt; \n";
}
?&gt;
</code></pre>

<p>The problem is it gives the list of files along with the various timestamps of the filenames-</p>

<pre><code> Volume in drive F is Movies 
 Volume Serial Number is 172B-1DE0 
 06/17/2011  01:11 AM             6,318 bck.gif
</code></pre>

<p>Hence, here it creates clickable link to each line for the output which needless to say does not work.</p>

<p>What I want is that it will only create clickable links for the filenames and not the extra meta information, which the user can then click to launch his native program like this-</p>

<pre><code>video1.mpg
video2.mpg
bck.gif 
</code></pre>
