I want to make images shopping site in which I want people buy images then they can download them.
My problem is how to create hidden path to image that people download the image and don't know the real path of the image.
Asked
Active
Viewed 1,683 times
-1

Werner Henze
- 16,404
- 12
- 44
- 69

user2239044
- 13
- 7
-
sorry but i dont know how to start – user2239044 Apr 04 '13 at 09:01
2 Answers
2
You can call a php
file to download the image and not the real image/path.
Like this you can call the real path inside your php
file with something like:
$path = "/public_html/yourPath/";
if (! isset($_GET['img'])) {
die("Invalid URL");
}
$imageName = filter_var($_GET['img'], FILTER_SANITIZE_STRING);
$finalPath = $path.$imageName;
header('Content-type: octet/stream');
header('Content-Type: image/jpg');
header("Content-Disposition: attachment; filename=$finalPath;");
readfile($finalPath);
You can read more about it here.

Alvaro
- 40,778
- 30
- 164
- 336
-
Could you accept the answer if that's what you were looking for? Thanks. – Alvaro Apr 04 '13 at 09:31
0
Store the images in an offline location (not www) and retreive them with PHP, so they can access the image for example like this: http://yoursite.com/index.php?file=filename and then PHP will go and return that file from the offline location. You just need to set the correct headers so the content is not treated like a web page but an image instead. Now obviously, such link is still public so you need to add some more information to it to authenticate the downloader.

cen
- 2,873
- 3
- 31
- 56