[PHP-users 12429] Re: tifファイルが開けない

Kawano Yasuhisa php-users@php.gr.jp
Wed, 08 Jan 2003 10:33:59 +0900


初めまして、かわのと申します。

私も気になったのでちょっと調べてみました。

> > $_SESSION("hoge") を
> > $_SESSION["hoge"] にするといけるのではないでしょうか。
> 
> ご指摘の箇所を試してみましたが、結果に変わりありません
> でした。
> 
> またソースを以下のように変更してみましたが、結果は同じでした。
> 1  <?php
> 2  session_start();
> 4  header("Content-type: image/tiff");
> 5  header("Content-Disposition: inline; filename=test.tif");
> 6  header("Content-length: " . filesize("/data/test.tif"));
> 7  readfile("/data/test.tif");
> 9  ?>
> 
> この場合でも「session_start()」を外すと正常に実行されます。

session_startの有無で動作が違うということなので、ヘッダを見てみました。
すると以下のような違いがありました。

動かない場合

HTTP/1.1 200 OK
Date: Wed, 08 Jan 2003 01:07:09 GMT
Server: Apache/1.3.26 (Unix) mod_jk PHP/4.2.2
X-Powered-By: PHP/4.2.2
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Disposition: inline; filename=test.tif
Content-length: 22296
Keep-Alive: timeout=15, max=100
Proxy-Connection: Keep-Alive
Connection: Keep-Alive
Content-Type: image/tif

動く場合

HTTP/1.1 200 OK
Date: Wed, 08 Jan 2003 01:08:58 GMT
Server: Apache/1.3.26 (Unix) mod_jk PHP/4.2.2
X-Powered-By: PHP/4.2.2
Content-Disposition: inline; filename=test.tif
Content-length: 22296
Keep-Alive: timeout=15, max=100
Proxy-Connection: Keep-Alive
Connection: Keep-Alive
Content-Type: image/tif

ということで、キャッシュが関係しているようです。

そこで、同じような内容が出力されるようにsession_cache_limiterにnoneもし
くはprivateを設定してみたところ、表示されるようになりました。

ちなみにprivateの場合
HTTP/1.1 200 OK
Date: Wed, 08 Jan 2003 01:30:49 GMT
Server: Apache/1.3.26 (Unix) mod_jk PHP/4.2.2
X-Powered-By: PHP/4.2.2
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: private, max-age=10800, pre-check=10800
Last-Modified: Wed, 8 Jan 2003 01:30:28 GMT
Content-Disposition: inline; filename=test.tif
Content-length: 22296
Keep-Alive: timeout=15, max=100
Proxy-Connection: Keep-Alive
Connection: Keep-Alive
Content-Type: image/tif

noneの場合
HTTP/1.1 200 OK
Date: Wed, 08 Jan 2003 01:29:28 GMT
Server: Apache/1.3.26 (Unix) mod_jk PHP/4.2.2
X-Powered-By: PHP/4.2.2
Content-Disposition: inline; filename=test.tif
Content-length: 22296
Keep-Alive: timeout=15, max=100
Proxy-Connection: Keep-Alive
Connection: Keep-Alive
Content-Type: image/tif

参考になれば幸いです。

かわの