I am making a website which will stream a selected video. I could make it show the file list. What I want is, when I select a file from list, it pastes filename into source link for video streaming. I cannot get this file name from the list that I got. Can anyone help me, please? Don't be mad, I'm just a beginner in this.
<form action="" method="post">
<?php
//scans files and sorts by date
$files = glob('/media/*.MP4');
usort($files, function($a, $b) {
return filemtime($a) < filemtime($b);
});
// outputs a list of files, sorted by name
foreach($files as $file){
printf('<p><tr><td><input type="radio" id="%1$s" name="box"></td>
<td><label for="%1$s">%1$s</td></label>
<td><label for="%1$s">%2$s</td></label></tr></p>',
basename($file), date('F d Y, H:i:s', filemtime($file)));
}
?>
<input type="submit" name="submit1" value="Submit"><INPUT type="reset">
</form>
<video width="320" height="240" controls>
<source src="/media/<?php printf($_POST); ?>" type="video/mp4"> <--- I want to put the file name in this line
</video>