新しいフォルダのファイルを作成し、ここにすべての曲を移動し、新しい.htaccessファイルを作成し、次の行を追加:フォルダのメンバー中に、
Order Deny,Allow
Deny from all
をファイルget_file.phpを作成し、次のコードを追加します。 ?ファイルを取得する
if(!empty($_GET['name']))
{
// check if user is logged
if(is_logged())
{
$file_name = preg_replace('#[^-\w]#', '', $_GET['name']);
$question_file = "{$_SERVER['DOCUMENT_ROOT']}/files/questions/{$file_name}.zip";
if(file_exists($question_file))
{
header('Cache-Control: public');
header('Content-Description: File Transfer');
header("Content-Disposition: attachment; filename={$question_file}");
header('Content-Type: application/zip');
header('Content-Transfer-Encoding: binary');
readfile($question_file);
exit;
}
}
}
die("ERROR: invalid song or you don't have permissions to download it.");
URL:ローカルホスト/ get_file.php名= file_nameに
はhttp://stackoverflow.com/questions/13881041/htaccess-deny-acces-to-directoryを見てください-if-logged- out-checked-with-phpを使って、これをPHPでどのように行うことができるかを確認してください。 – Chris
そのブロックではない直接ファイルのリンク.. PHPのファイルにログインしていない場合は、ちょうどリダイレクト –