-2

I have a PHP script that is responsible for outputing and streaming MP3 files to the browser, my questions is

How can I prevent downloading the MP3 file?

*knowing that I tried using HTTP Referrer and it worked ((only on my localhost)) detecting the direct downloads of the file but not on my server

jww
  • 97,681
  • 90
  • 411
  • 885
John Max
  • 1
  • 1
  • 2
    Possible duplicate of [What is an effective way to protect mp3 files from download?](https://stackoverflow.com/q/2228636/608639), [Is it possible to protect from downloading a video from a site](https://stackoverflow.com/q/1790190/608639), etc. – jww Oct 11 '18 at 04:35

1 Answers1

1

How can I prevent downloading the MP3 file?

You can't.

You can't send someone data in a way that they can't receive the data. If they can play it, they can download it. It's the same action.

At best, you can digitally watermark your media with unique identifiers so that if someone re-shares the content, you can trace it back. You can also prevent someone from sharing a link to media by using signed URLs or otherwise one-time-use (or time-limited) URLs.

Brad
  • 159,648
  • 54
  • 349
  • 530