Similar types of questions are already asked but none is helpful. I want to display working audio file (.mp3 or .wav) in php page from mysql database. I tried my best but the audio file is not playing., #code1
<html>
<form method="post" action="searchbook.php">
<div class="search">
<input type="text" name="searchword" class="searchTerm">
<button type="submit" class="searchButton">SEARCH</button>
</div>
</form>
</html>
From above file I passed user entered value to below searchbook.php file, #code2
<html>
$searchword=$_POST['searchword'];
$con=mysqli_connect('localhost','root','','bookspyramid');
$sql="SELECT audiono FROM bookinfo where bookname like '%$searchword%'";
if($result=mysqli_query($con,$sql))
{
if(mysqli_num_rows($result)>0)
{
while($row=mysqli_fetch_array($result))
{
echo "<a href='..\datafile/viewaudio.php?del=$row[audiono]'>Download AudioBook </a>";
}
}
}
</html>
From above code I passed value of audiono to below viewaudio php file, #code3
<html>
<?php
$remitem=$_GET['del'];
$con=mysqli_connect('localhost','root','','bookspyramid');
?>
<audio controls style="width: 90%; margin-left: 5%;">
<source src="data:audio/wav;base64,<?php echo base64_encode($remitem); ?>" type="audio/wav">
</audio>
</html>
If instead of just above code I write below code then file successfully gets downloaded, #code4
<?php
$remitem=$_GET['del'];
header('Content-type: application/audio');
header('Content-Disposition: inline; filename="' . $remitem . '"');
header('Content-Transfer-Encoding: binary');
header('Accept-Ranges: bytes');
@readfile($remitem);
?>
But if I want to show the audio format(online play). In Edge it is displaying 'This type of audio file isn't supported'
In output of #code3, audiofile is showing but it is not working(gray in colour). I want it to work.