Jump to content

using php to secure folders


JonnySnip3r

Recommended Posts

Hey guys i am making a php application and i have a feature where it allows members to upload images. If there a way to secure a folder to only be allowed access when a member is logged in and not someone accessing the folder and downloading images.

 

Stuped question i know would it be better to store the images in the database as BLOB? but then again could make the database big. Thanks

Link to comment
https://forums.phpfreaks.com/topic/210091-using-php-to-secure-folders/
Share on other sites

put .htaccess with deny from all in the image directory.

 

then use a php file to retrieve images:

 

<?php
// image.php

$name = str_replace(array('/', '\\'), "", $_GET['name']);
$image = file_get_contents('images/' . $name);

header("Content-type: image/jpg");
echo $image;

exit();

?>

 

And then, in HTML:

<img src="image.php?name=some_image.jpg" />

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.