Jump to content

Recommended Posts

hi all

 

i am start work on a music selling website in PHP.

 

normally when we listen to music mp3 file it gets saved in temporary files of the browser from where people can save it.

 

how can i stop the files from getting downloaded in the temp folder of browser.

 

Please everybody tell your opinion otherwise it would be difuclt to start project.

 

i m new to this kind of situation.

 

vineet

Link to comment
https://forums.phpfreaks.com/topic/176921-stop-music-files-from-downloading/
Share on other sites

hi Madtechie

 

This is a good idea. If didnt find anyother solution then i have to follow it.

 

vineet

 

Technically for something to play on your PC it needs to "downloaded" the media so users could save anything your site supplies, your best and simplest solution is to only allow sample downloads

No options will be 100%, I could always set my PC to record from my Mic and Play from speaker and connect the ports together.. (that's low-tech but you get the idea)

 

however.. it maybe worth looking into media steaming server, however that can be captured but is a little harder then just grabbing from temp,

 

If you had to play a full MP3 and wanted to "reduce" the risk.. then maybe try getting a flash MP3 player

 

The have the flash player, play a MP3 that's parsed via a PHP script, the PHP script loads the files from a folder outside the public domain and requites a token sent from the flash player

 

so the flash player would load a file like

getMP3.php?file=madtechie.mp3&token=465f7846abce

the getMP3.php will check the token with the session, then generate a new token and then open the MP3 from its folder

Hi madTechie

 

I dont know much about flash player

But you mean to say that the mp3 folder should not be inside root folder and flash player will look for an id of that mp3 file.

 

i didnt understand the token. is it ID of the mp3 file.

 

vineet

 

The have the flash player, play a MP3 that's parsed via a PHP script, the PHP script loads the files from a folder outside the public domain and requites a token sent from the flash player

 

so the flash player would load a file like

getMP3.php?file=madtechie.mp3&token=465f7846abce

the getMP3.php will check the token with the session, then generate a new token and then open the MP3 from its folder

okay..

just say you have 3 files on your server Hello1.mp3, Hello2.mp3 & Hello3.mp3

 

ie

/

/Hello1.mp3

/public_html/

/public_html/tester.php

/public_html/Hello2.mp3

/public_html/tester/

/public_html/tester/Hello3.mp3

 

now to play Hello2.mp3 you do http://domain.com/Hello2.mp3

and to play Hello3.mp3 you do http://domain.com/tester/Hello2.mp3

 

but you can't play Hello1.mp3 as its not in the public folder.. Right ?

 

But if tester.php was

<?php
header("contents-type: audio/mp3");
readfile('/Hello1.mp3');
?>

then opening tester.php would infact open Hello1.mp3 but with the bonus of PHP being in control.. so no direct downloads  :)

 

As for the token..

just say we goto page1.php and on page 1 we have a

<?php
session_start();
$_SESSION['token'] = md5(uniqid(mt_rand(), true));

echo "tester.php?file=madtechie.mp3&token=465f7846abce";
?>

 

and tester.php checks the token like this

<?php
session_start();
if($_GET['token'] != $_SESSION['token']) die("ERROR");
$_SESSION['token'] = "VOID"; //remove token we are done 
header("contents-type: audio/mp3");
readfile('/'.$_GET['file']);//YOUR NEED TO FILTER $_GET['file']
?>

 

Now if the token is different then we get nothing :)

hi MadTechie

 

thanks for explanation.

 

but this script will prevent only direct downloading from url. that i understood.

 

but if the token is corect then still the song will get download in temp folder and user can save it.

 

Or with flash player the songs doesnt get downloaded in temp folder.

 

Am i correct.

 

vineet

Another option is to provide a lower quality mp3 as a preview of the higher quality one. That way the listener gets a feel for the music, but won't really get a crystal clear sound.

 

Possible settings:

 

High quality: 192 kbit/s

Sample/preview quality: 96 kbit/s

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.