|
||||||
| PHP Forum Use this forum to discuss all aspects of PHP Development. PHP is a server-side, cross-platform, HTML embedded scripting language that lets you create dynamic web pages. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Hi,
I need some help/ideas with this : I'm using session for user's authorization and need to access "private" image data or access to some directory for authorized user only. My question is how to protect images (image file or directory) with session (I mean no HTTP basic authentication scheme is allowed) ? I've tried something like this, but it doesn't work properly probably due to the directory rights. Code:
<?php
function LoadJpeg($imgname)
{
$im = @imagecreatefromjpeg($imgname);
if (!$im) { /* See if it failed */
/* Output an errmsg */
}
return $im;
}
/* if (user logged in) */
header("Content-Type: image/jpeg");
$img = LoadJpeg("private/image.jpg");
imagejpeg($img);
?>
TIA Last edited by elle; 07-19-2007 at 06:47 PM. |
| Sponsored Links |
|
|
|
|||
|
Actually the code above is really correct. Some modification can be still applied I mean replace creatimage function with some direct stream read function (avoiding of compression) but this still doesn't solve the image protection in the directory. The solution is to use .htaccess on it with deny to show images.
That's it. |
|
|||
|
Actually I'm using some freeweb hosting and there's no way how to access directory out of the web root. So .htaccess works pretty well for me now.
I'm using this one inside the image folder: Code:
<FilesMatch "\.(jp?g)$"> order deny,allow deny from all </FilesMatch> elle |
| Sponsored Links |
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| trademark or copyright protection | Masterguns | Business and Legal | 3 | 10-20-2007 01:07 PM |
| Keyboard Protection for Laptops | kseine | Computer Hardware | 1 | 06-14-2007 09:04 AM |
| object in session.... "<logic:present>" with JSTL? | reachpradeep | Java Help | 0 | 03-04-2007 09:46 AM |
| WingedPanther | ........ | 2753.6 |
| Xav | ........ | 2704 |
| Brandon W | ........ | 1702.32 |
| John | ........ | 1207.73 |
| marwex89 | ........ | 1175.24 |
| morefood2001 | ........ | 966.05 |
| dcs | ........ | 655.75 |
| Steve.L | ........ | 475.59 |
| orjan | ........ | 418.58 |
| Aereshaa | ........ | 383.54 |
Goal: 100,000 Posts
Complete: 98%