I have a code that lists all files in a dir. The code looks something like this:
//path to directory to scan
$directory = "../images/team/harry/";
//get all image files with a .jpg extension.
$images = glob($directory . "*.jpg");
//print each file name
foreach($images as $image)
{
echo "some.php?file=".$image;
}
In the link part where it says echo "some.php?file=".$image; I need to identify each file uniquely and forward it by $_GET or $_POST or something to the next page. However, the file names may contain special characters (diacritics), spaces etc. as they are uploaded by users by FTP. What would be a good way to identify them in the next page? Something like an ID, maybe base64_encode / decode or similar? (using simply a counter may not be reliable as the files may get deleted in the mean time which would yeld a wrong result)
Base64 would probably do the trick nicely:
and on the page receiving the get query:
Another suggestion is to use a database to store user’s uploaded files. Upon upload, each image will be stored in the DB with example columns of an ID, and filename. Then you can just assign the GET var that ID, and on the otherside pull the filename from the given ID.