Jump to content

Prevent direct file download

- - - - -

  • Please log in to reply
1 reply to this topic

#1
reservoirdog1985

reservoirdog1985

    Newbie

  • Members
  • Pip
  • 2 posts
Hi all,
I have some problems with a PHP site that includes some FLV files in a video player.

I'd like to avoid people from downloading the videos by typing the url by hand (ex. http://mysite.com/video/vidTitle.flv), but at the same time, I need the same url to be accessed by the video player on my PHP page.
This video player uses an anchor tag: <a href="/video/vidTitle.flv">...</a>

How can I avoid the direct download from the address bar?
Thanks!

#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200
You could generate a token that lasts once per link (on every link), and check this before serving the actual flv. You would simply need a PHP file to handle this, it would compose of verifying the token, and then using sendfile() to send the flv to the client as if it were an flv page with added authentication.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users