Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

for mp3 file error : the file extension is incorrect, or the file is corrupt

I put the mp3 file in the database and give an option to user download this file through the button

<div class="item-box-light-lg mb-30">
  <audio controls>
    <source src="music/<?php echo $row['music'] ; ?>" type="audio/ogg">
    <source src="music/<?php echo $row['music'] ; ?>" type="audio/mpeg">
    Your browser does not support the audio element.
  </audio>
<br><br>
<form action="download.php" method="post" name="downloadform">
   <input name="file_name" value="<?php echo $row['music'] ; ?>" 
                                                type="hidden">
   <input type="submit" class="btn-ftf-dtp-52" value="Download the MP3">
</form> 

download.php

<?php
  if(isset($_POST['file_name'])){
   $file = $_POST['file_name'];

   header('Content-type: audio/mpeg3');
   header('Content-Disposition: attachment; filename="'.$file.'"');
   readfile('mystery_folder/'.$file);
   exit();
  }
 ?>

so problem is that when user click on on download button file download successfully but when this mp3 file try to open in media player(i tried all player like vlc, grrome) error showing - 'This file isn't playable. That might be because the file type is unsupported, the file extension is incorrect, or the file is corrupt'.

Another question is raised: is the file really corrupt? Before I put mp3 file in database mp3 file running cleaning in all media player but when I download this mp3 file from my site that error showing.

Comments