このフォルダにはWebからアクセスできないようにすることができます(たとえば、htdocsの外にフォルダを置くか、.htaccessルールを追加するなど)。
プライベートイメージへのすべての要求を処理するPHPスクリプトを作成します。ユーザーが
-checkを認証されている場合、ユーザーが画像を開いて、ブラウザに
を、それを印刷要求した画像を表示することが許可されている場合(あなたが設定する必要が
-checkを:このスクリプトは、次の操作を実行する必要があります必ず内容を画像として処理されていることを確認するための正しいHTTPヘッダ)
デモ
getimage.php
if (LoggedInUserCanAccessThisFile())//this is optional user define function as requirement if you want that only login user can see image then with the help of your session variables or cookies you can return this function true or false
{
$file = 'privatedir/image.jpg';
$type = 'image/jpeg';
header('Content-Type:'.$type);
header('Content-Length: ' . filesize($file));
readfile($file);
exit();
}
home.php/otherpage.php
<img src="getimage.php" />
(あなたは= "ユーザーID = 123?getimage.php" とgetimage.phpとチェックに入るSRCを使用することができ、このユーザーが表示するためにはログインするかしません画像)
(また、あなたが動的な画像コードのSRC = "getimage.php?ユーザーID = 123 & imgfilename = image3.jpg" を使用して
$file = 'privatedir/'.$_GET["imgfilename"];
としてgetimage.phpに取得することができます)
リファレンス:http://www.naturefocused.com/articles/image-protection.html –