目次 |
---|
・ファイルダウンロード ・サンプルコード ・サンプル |
ファイル形式 | Content-Type | |
HTML | text/html | |
PLAIN テキスト | text/plain | |
CSS | text/css | |
JPEG | image/jpeg | |
GIF | image/gif | |
application/pdf | ||
tar | application/x-tar | |
zip | application/zip | |
CSV | application/x-csv | |
Excel | application/vnd.ms-excel | |
powerpoint | application/vnd.ms-powerpoint |
(php部 :download.php ) <?php // ダウンロード元ファイルを指定します。ファイルパス(絶対パス、ファイル名まで含む)を指定します。 $fullpath = 'path/Sunset.jpg'; // 保存時のファイル名を設定します。 $filename = 'Download_Sunset.jpg'; // HTTPヘッダ送信 header("Content-type: image/jpeg"); header("Content-Disposition: attachment; filename=$filename"); // ファイルを読み込んで出力します。 readfile($fullpath); ?>
(html部 : download.html ) <form method="post" action="download.php"> <input type="submit" value="ダウンロード"> </form>