teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

注記

2016/07/01 07:57

投稿

yambejp
yambejp

スコア117912

answer CHANGED
@@ -8,7 +8,7 @@
8
8
  }elseif(preg_match("/\.(jpg|png|gif)$/",$file)){
9
9
  header("Content-type: application/octet-stream");
10
10
  header("Content-Disposition: attachment; filename=\"$file\"");
11
- fread($file);
11
+ readfile($file);
12
12
  exit;
13
13
  }else{
14
14
  print "not image!";
@@ -19,5 +19,6 @@
19
19
  <a href="imgdownload.php">指定なし</a>
20
20
  <a href="imgdownload.php?file=1.hoge">存在しない</a>
21
21
  <a href="imgdownload.php?file=1.txt">1.txt</a>
22
- <a href="imgdownload.php?file=1.jpg">1.jpg</a>
22
+ <a href="imgdownload.php?file=1.jpg">1.jpg(カレントのファイル)</a>
23
+ <a href="imgdownload.php?file=images/2.jpg">images/2.jpg(相対パスOK)</a>
23
24
  ```