Sunday, 15 September 2013

Getting a download.mp3 or download.php file instead of TMH.mp3 file by download.php script

Getting a download.mp3 or download.php file instead of TMH.mp3 file by
download.php script

i have created a download.php file as
include('../../../phpsqlconnect.php');
$sel = mysqli_select_db($link, 'download');
$id=$_GET['id'];
if(is_numeric($id)){
$result = mysqli_query($link, 'SELECT * FROM song WHERE id=$id');
$row = mysqli_fetch_assoc($result);
$url = $row['url']; // of course find the exact filename....
$name = $row['name'];
header( 'Pragma: public' ); // required
header( 'Expires: 0' );
header( 'Cache-Control: must-revalidate, post-check=0, pre-check=0' );
header( 'Cache-Control: private', false ); // required for certain browsers
header( 'Content-Type: application/octet-stream' );

header( 'Content-Disposition: attachment; filename="'. basename($url) .
'";' );
header( 'Content-Transfer-Encoding: binary' );
header( 'Content-Length: ' . filesize( $url ) );

readfile( $name );

exit;
}

this download.php is within a song folder & within song folder i have
ppnh13 folder which have ppnh.php fle
i have a download database & song table within it.
table song have 4 rows as id,url,name,movie...
in $row['url'], i have my file location as ppnh13\TMH.mp3
in $row['name'] , i have my file name as TMH



when i open the link < href="../download.php?id=1">TMH from ppnh.php file
i am getting a download.mp3 or download.php file instead of TMH.mp3 file

i want to make a common download.php file for all the folders within
folder song.

No comments:

Post a Comment