とにかく何でもコンテンツをダウンロードさせる方法

カテゴリ コンテンツの作成 コアバージョン 8.4x 関連モジュール Download
$path = ファイルへのパス;
$basename = basename($path);

header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Transfer-Encoding: binary");
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="' . $basename . '"');
header('Content-Length: ' . filesize($path));
header('Cache-Control: max-age=0');

$result = readfile($path);
exit();

OTHER FAQ

Drupal開発・運用の疑問/質問の答えはここに

無料ユーザー登録すると質問できます。

カテゴリ Core Ver. 関連モジュール昇順で並び替える タイトル
ユーザ 7.22 Realname ユーザーIDではなくニックネーム等を表示したい
ユーザ 7.44 Quickbar 会員の種別(役割)別にメニューを設けたい
SSH 7.50 ProxyCommand SSH IP制限を1コマンドで通過する
Proxy 7.59 Proxy Apache settings.php リバースプロキシ(Apache)+バックグランドWeb(Drupal 7 )でログインセッションを維持する方法
サイトの構築 7.19 Plesk Pleskでdrupal7(プライベートファイルシステム)を使う場合の注意点
コンテンツの作成 8.4x PhpSpreadsheet Excelを読み書きする方法
ユーザ 7.23 PHP user_load_multiple()の復帰値
コンテンツの作成 7.26 PHP ノード内の一部(フィールド)を変更する
アップデート 8.9.x PHP CentosでPHPのバージョンアップ(例:5.3->5.6)を行う方法
コンテンツの管理 7.16 PHP 好きなところにノードを埋め込みたい
ユーザの管理 7.27 PHP 新規ユーザーの追加ができない
JavaScript 8.5.x PHP Commerce決済モジュール設定をJavaScriptにデータに渡す方法
JavaScript 7.34 PHP PHPからJavaScriptに変数値を渡したい
PHP 8.3x PHP drupa8でhook_init()する方法
チューニング 7.26 PHP DrupalはNginxで動く?
PHP-FPM 8.9.x PHP PHP-FPM 環境で .htaccess に php_value を 書いてもダメ
PHP 8.9.x PHP YamlをPHP配列にする方法
PHP 7.22 PHP ノードに付いたコメントを好きな場所に表示する
Database 7.34 PHP データベースクエリ(SELECT)時のSQL関数
ユーザの管理 7.50 Paypal continued billing drupal7のPaypal継続課金モジュールについて

ページ