3

I created an upload file in html and a php file for inserting audio file name into table,uploading to particular folder in server. Everything works fine if i use simple php coding like this:

<?
require 'dbconnect.php';
$audio=basename($_FILES['file']['name']);
$audio=str_replace(' ','|',$audio);
//$date=date('YmdHis');


$audio=$audio.".mp3";
$tmppath1="audios/".$audio;
move_uploaded_file($_FILES['file']['tmp_name'],$tmppath1);
$query="INSERT INTO `tbl_audio` (`audioname`, `guid`) VALUES ('$audio', '$guid');";
$res=mysql_query($query);
if($res)
{
$message=array("message"=>"uploaded");
$query1="select * from tbl_audio order by date desc";
$res1=mysql_query($query1);
$row1=mysql_fetch_row($res1);
if($row1[1])
{
$audiopath="http://test.com/audios/".$row1[1];
/* get the short url */
$short_url = get_bitly_short_url($audiopath,'XXXXXXXXX','XXXXXXXXXXXX');
}
else
{
$audiopath="";
}
$message=array("audioid"=>$row1[0],"audiopath"=>$short_url,"key"=>"uploaded","guid"=>$row1[3],"audioname"=>$row1[1]);
}
else
{
$message=array("message"=>"failed to upload");
}
}
echo json_encode($message);

But my superior told not to directly display the actual path of audio file and name,instead use jwplayer to hide it. the code look like:

<script type='text/javascript' src='jwplayer/jwplayer.js'></script>

<div id='mediaplayer'></div>

<script type="text/javascript">
  jwplayer('mediaplayer').setup({
    'id': 'playerID',
    'width': '480',
    'height': '270',
    'file': 'http://test.com/test/audios/Testaudio.mp3',
    'modes': [
        {type: 'html5'},
        {type: 'flash', src: 'http://test.com/jwplayer/player.swf'},
        {type: 'download'}
    ]
  });

I am able to play the audio in browser. but how to change the url generated and give it as response to developer? what i want is to get the url path of the audio file with out its name like player.php?id=abc I used bitly api to reduce path Please help, Thanks...

Ramaraju.d
  • 1,301
  • 6
  • 26
  • 46

1 Answers1

1

I guess you need to modify the header.

inside the player.php you do the logic to find the physic path to the file you wan't to contribute.

then you have to change the header

here is an example in the first answer

Setting up apache to serve PHP when an MP3 file is requested

Community
  • 1
  • 1
Ello
  • 907
  • 1
  • 15
  • 33