I’m writing a CMS that user can post some news and comments. I have problems with images. would like to place all images of all posts in one folder and access them by post ID and image ID (starting from 0 for each post)
The only thing I can’t manage to do is producing image links in script. I saw some pages on net doing same thing. like this:
<img src=https://www.somewhere.com/uploads/image.php?postid=20&id=80>
EDIT: to clarify, supposing there is an image in http://www.somewhere.com/uploads/1_2.jpg how script can pass the image when https://www.somewhere.com/uploads/image.php?postid=x&id=y is the source of img tag in somewhere?
With $_GET[‘postid’] and $_GET[‘id’] you can read the requested postid and id as variables in images.php, and then return the header and the raw image data. Just a simple example, that you can explore:
I hope this will help you.
EDIT: You can use the postid and id to get the location of the image from a database etc.