I can't really match an answer to this issue so I've decided to post this question hoping to find a solution.
I would like to use preferably JQuery / javascript or even PHP to find the most recent JSON files in a specified directory.
Why I would like to do this? Because when a user of my html5/javascript webapplication saves some array of objects to a JSON file, then besides the original work JSON file, there is a backup file that is created with a random name and which is the exact copy of the original JSON file.
If something happens to the original JSON file I would like the user to be able to open the most recent backup files from the backups directoy and select the right one to be recovered.
To open a JSON file I usually use this code:
$.getJSON('main/backups/random1345004.json', function(info){ ... });
Now the trouble is that in case of a backup I don't know the name of the JSON file that should be opened, because each file is unic and has a Math.random() generated name when it's created.
So I repeat the question: Is there a way to open from the backups directory the most recently created, randomly named, JSON files?
If not I might try to use .getTime() javascript method instead of Math.random() to control the names of the backup files created and then use a loop to search for a valid backup file name. That's a hunch, but I would not like to make anything stupid if there is a better solution, without loops.
Security is not a concern for me at this rate.
Thank you for any help provided!