これが問題です。さまざまな種類の画像のリストを表示する必要があります。システム管理者は、セキュリティ上の理由から、これらすべてのイメージを webroot の外部に保持することにしました。私は画像を取得するためにいくつかの楽しいphpトリッキーを使用していますが、epsファイルを表示できず、tiffにも問題がありますが、EPSに集中しています。ところで、MVC を使用しているため、URL は関数を呼び出してパラメーターを渡す方法です。
これは、データベースからの画像パスのループを介して画像を表示する方法です
foreach($paths as $path){
// $path = '/0/path/1/to/2/image/3/filename.eps'
<img src="/path/to/script/0/path/1/to/2/image/3/filename.eps" />
}
そのスクリプトでは、次のことを行います。
$count = 0;
// BUILD SRC PATH FROM PASSED ARGUMENTS
while($this->_getParam($count) && $count < 30 ){
$path[] = urldecode($this->_getParam($count));
$count++;
}
$path = '/'.urldecode(implode('/',$path));
$srcESC = escapeshellarg($path);
$mime = exec('file -bi '.$srcESC);
if (!file_exists($path)) return;
switch($mime){
case 'image/x-MS-bmp':
header('Content-Type: image/x-ms-bmp');
break;
case 'application/postscript':
header('Content-Type: application/postscript');
break;
case 'image/gif':
header('Content-Type: image/gif');
break;
case 'image/x-ico':
header('Content-Type: image/x-icon');
break;
case 'image/jpeg':
header('Content-Type: image/jpeg');
break;
case 'application/pdf':
header('Content-Type: application/pdf');
break;
case 'image/png':
header('Content-Type: image/x-png');
break;
case 'image/svg+xml':
case 'image/svg-xml':
header('Content-Type: image/svg+xml');
break;
case 'image/x-tiff':
case 'image/tiff':
header('Content-Type: image/tiff');
break;
case 'image/x-photoshop':
case 'application/x-quark-xpress-3':
case 'application/pdf':
case 'application/octet_stream':
header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename='.basename($path));
header('Content-type: application/octet');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($path));
break;
}
readfile($path);
EPS は application/postscript Content_Type を取得する必要があります。これはヘッダーが chrome inspect を介して返すものですが、ファイルのビジュアルを取得することはできません。
何か案は?