Going through 10,000 files will certainly take a lot of time.
Another approach would be to store the name of the last uploaded file in a file. You can then open the file get its contents (the newest file's name).
PHP Code:
// upload here;
$name = 'name of the uploaded file';
// storing the name of the last uploaded file
$fp = fopen('lastuploaded', 'w');
fwrite($fp, $name);
fclose($fp);
// get the name
$fp = fopen('lastuploaded', 'r');
$data = fread($fp, filesize('lastuploaded'));
fclose ($fp);
echo 'last uploaded file was: ', $data;
Another way would be to store the name in a database.
Bookmarks