Good night, Stack Overflow folks, I'm writing a playlist system in PHP, it's still under development so to test the songs I've listed the links of each song in the chosen directory, but then the links did not take me to the file as in file: /// home / (...) musica.mp3 , but by copying the link and pasting in a new tab Chrome played the song. After many attempts and changes in the source code, I tried debugging in Chrome itself and received as a result Not allowed to load local resource: file: /// home / zenas / Music / [1967]% 20-% 20Magical% 20Mystery% 20Tour / 04% 20-% 20Blue% 20Jay% 20Way.mp3 . How to solve this problem ?! Here are the codes:
Index.php
<?php
header('Content-type: text/html; charset=ISO-8859-1');
echo '<form action="list.php">';
echo "<h4>Write your songs folder</h4><br>";
echo "<h5>(DON'T WRITE A BAR IN THE END OR WRITE ANY SPECIAL CHARACTER)</h5>";
echo '<input type="text" name="folder">';
echo '<input type="submit">';
echo "</form>";
list.php
<?php
header('Content-type: text/html; charset=ISO-8859-1');
$folder = $_GET["folder"];
$files = "{$folder}/".$_GET['/*.*'];
if(isset($_GET['folder']) && file_exists("{$folder}/".$_GET['/*.*'])){
$fold = opendir($folder);
while (false !== ($filename = readdir($fold))) {
if (substr($filename,-4) == ".mp3") {
echo "<a href=\"file://$folder/$filename\">$filename</a><br>";
}
}
}