Reputation: 1881
My PHP script is in direcoty /home/foo/public_html/php_script/index.php
In this directory there is folder named images and it contains some images. How can I get the permanent download link to these images.
e.g http://www.example.com/~foo/php_script/images/image.gif
Upvotes: 0
Views: 614
Reputation: 1678
This question doesn't really make sense to me. Seems to me that you shouldn't need to do anything special, just link to your pictures... So use that URL example you gave, that should work already.
Since you're asking this question, I suppose you've tried that already? What web server are you using?
In your index.php, I'd just roll with something along the lines of...
<?php>
echo "<img src=\"/~foo/php_script/images/image.gif\" />";
</php>
But perhaps I'm being a newb and really missing the question...?
Upvotes: 1
Reputation: 4454
Have a function doing this
header("Content-Transfer-Encoding: binary");
header("Content-Type: image/jpg");
header("Content-Disposition: attachment; filename=$filename");
readfile($filename);
and call this function upon clicking the download link
see here for readfile info
http://php.net/manual/en/function.readfile.php
Upvotes: 0