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

質問編集履歴

1

解決のまとめ

2020/11/10 01:33

投稿

kuma903
kuma903

スコア9

title CHANGED
File without changes
body CHANGED
@@ -26,4 +26,36 @@
26
26
  header('Content-Type: image/jpeg');
27
27
  print file_get_contents($url, false, stream_context_create($options));
28
28
 
29
- ```
29
+ ```
30
+ ### 解決した結果
31
+ ご提案により、解決致しましたので後学のため記述します。
32
+ 以下のphotoreturn.phpを表示させたいファイルのあるディレクトリに配置
33
+ ```php
34
+ <?php
35
+ $img = $_GET['img'];
36
+ $img= '/FULLPAS/web/image/'.$img;
37
+ header('content-type: image/jpeg');
38
+ readfile($img);
39
+ ```
40
+ 以下、表示させたいHTMLファイルなど
41
+ ```HTML
42
+ <!DOCTYPE html>
43
+ <html lang="ja">
44
+ <head>
45
+ <meta charset="UTF-8">
46
+ <title>Document</title>
47
+ </head>
48
+ <body>
49
+ <img src="photoreturn.php?img=1.jpg" alt="">
50
+ <img src="photoreturn.php?img=2.jpg" alt="">
51
+ </body>
52
+ </html>
53
+ ```
54
+ 以下の.htaccessを画像のある別ディレクトリに配置
55
+ ```.htaccess
56
+ Order deny,allow
57
+ Deny from all
58
+ ```
59
+ ### 参考サイト
60
+ [.htaccessの記述方法](https://teratail.com/questions/6219)
61
+ [phpファイルについて](https://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q14184602829?__ysp=cGhwIOeUu%2BWDjyDjgqLjgq%2FjgrvjgrnliLbpmZAg44OJ44Kt44Ol44Oh44Oz44OI44Or44O844OI5aSW)