私はdownload.phpファイルを作成しました
include('../../../phpsqlconnect.php');<br/>
$sel = mysqli_select_db($link, 'download');<br/>
$id=$_GET['id'];
if(is_numeric($id)){<br/>
$result = mysqli_query($link, 'SELECT * FROM song WHERE id=$id');<br/>
$row = mysqli_fetch_assoc($result); <br/>
$url = $row['url']; // of course find the exact filename....<br/>
$name = $row['name']; <br/>
header( 'Pragma: public' ); // required<br/>
header( 'Expires: 0' );<br/>
header( 'Cache-Control: must-revalidate, post-check=0, pre-check=0' );<br/>
header( 'Cache-Control: private', false ); // required for certain browsers<br/>
header( 'Content-Type: application/octet-stream' );<br/>
header( 'Content-Disposition: attachment; filename="'. basename($url) . '";' );<br/>
header( 'Content-Transfer-Encoding: binary' );<br/>
header( 'Content-Length: ' . filesize( $url ) );<br/>
readfile( $name );<br/>
exit;
}
このdownload.phpは曲フォルダー内にあり、曲フォルダー内にはppnh.phpファイルを持つppnh13フォルダーがあり
、その中にダウンロードデータベースと曲テーブルがあります。
table song には id,url,name,movie... として 4 つの行があり
ます
。
TMHとして
リンクを開くと、< href="../download.php?id=1">TMH</> from ppnh.php file<br/>
TMH.mp3 ファイルの代わりに download.mp3 または download.php ファイル
が表示されます。フォルダの曲内のすべてのフォルダに共通の download.php ファイルを作成したいと考えています。