I have a simple upload/retrieval script to retrieve imaged from my database. When I upload files the script stores them in upoadsFolder/
. Ihen I want to display retrieve images I use the following code:
<?php
include('./dbconn.php');
$q=$dbconnection->query('SELECT * FROM img_table WHERE id=7');
$row=$q->fetch();
$row['imgpath'];
echo "<img src=uploadsFolder/$row['imgpath'] />";
But if the user knows or can predict any of my images names, e.g nameX.png
he will easily view these images by modifying the HTML <img>
tag: <img src=uploadsFolder/nameX.png />
.
How can I protect uploadsFolder/
to prevent this?
MOREOVER : The user also will be able to view whole content of my ' 'uploadsFolder/'
contents if Only he typed in his/here browser the URL: " localhost/uploadimages/uploads/ "
!!! See the attached !