私はPHPを使用してフォルダからファイルをダウンロードするために以下のスクリプトを用意していますが、ローカルで作業していますが、オンラインでダウンロードしてダウンロードしています。PHPはダウンロードの代わりにファイルを読み込んでいます
if($result && count($result) > 0){
$row = $result[0];
$book = true;
$Location = './files/';
$bookLocation = $Location . $row['file_name']; // exampe: report.zip
if(file_exists($bookLocation)){
$fileLocation = $bookLocation;
$file_size = filesize($fileLocation);
echo 'Please wait downloading the file....';
header('Content-Description: File Transfer');
header('Content-Type: application/force-download');
header('Content-Disposition: attachment; filename=' . $row['file_name']);
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . $file_size);
ob_clean();
flush();
readfile($fileLocation);
exit;
}else{
echo '<h3>Sorry!, file not found...</h3>';
}
}
.htaccessのスクリプトの助けを
RewriteEngine on
RewriteRule ^$ index.html
RewriteRule ^index.html$ index.php
RewriteRule ^([0-9]{1,9})(/)([^/\.]+[^/\.]+)(_+[^/\.]+)(\.html|)/?$ index.php?id=$1&cat=$3
RewriteRule ^([^/\.]+[^/\.]+)(\.html|)/?$ index.php?page=$1
RewriteRule ^(.*)(/)([0-9]{1,9})(/)(.*)(\.html|)/?$ index.php?view_file=$3&file=$5
RewriteRule ^(.*)(/)([0-9]{1,9})(/)(.*)(\.htm)/?$ index.php?download=$3
RewriteRule ^(author)(/)(.*)(.html)/?$ index.php?user=$1
感謝。
は、ブラウザからそれを実行していないとライン
を交換してみてください? – zod
リンクで新しいファイルを作成しようとしました..このファイルへのリンクは.. ..新しいページを実行してリンクをクリックしようとしました!! – zod
サーバーは最終的にヘッダーを変更しますか? – evotopid