Put audio file to download and listen in php

Asked

Viewed 658 times

1

I have some audios on my server and wish to put them online so that it is possible for the client side to have access, both to listen and download. I am working with php and a linux server, a debian version.

<td> 
        <audio controls="controls">
             <source src="teste.mp3" type="audio/mp3" />
         </audio>
  </td>

this is an example found on the internet, however when I put the path of my file I cannot access it, either to download or listen.

So, what is the best way to download and listen online a wav file from my server in an online application

1 answer

1

<td> 
<audio controls="controls">
<source src="teste.mp3" type="audio/mp3" />
</audio>
</td>
<br />
<a href='forcardownload.php?arquivo=teste.mp3'>Baixar MP3</a>

Take a look at how to create a forced file download script: HERE

Note: Be aware of the security issues in the text of the link informed.

  • But for example only if I inform the file path on the server in the scr field it is already possible to download the client side?

  • 90% of browsers nowadays do not download anymore, it is play directly in the browser, so I am indicating to you the link to create a PHP script that forces the download.

  • 1

    Got it, thanks a lot for the help. I’ll check the link

Browser other questions tagged

You are not signed in. Login or sign up in order to post.