bsamson Posted August 10, 2010 Share Posted August 10, 2010 Hello. I have a directory with files that look like this: priceguide_20100809.pdf priceguide_20100808.pdf priceguide_20100807.pdf priceguide_20100806.pdf I am trying to come up with a function that will grab and save the filename with the biggest date .. ie: priceguide_20100809.pdf. Any assistance would be greatly appreciated!! Quote Link to comment Share on other sites More sharing options...
bsamson Posted August 10, 2010 Author Share Posted August 10, 2010 Found this great code that lists the file by timestamp ... exactly what I needed. Hope this helps someone else. define ("FILEREPOSITORY", "/home/nxsap/public_html/uploads/"); if (is_uploaded_file($_FILES['priceguide']['tmp_name'])) { if ($_FILES['priceguide']['type'] != "application/pdf") { echo "<p>Class notes must be uploaded in PDF format.</p>"; } else { $name = "priceguide"; $result = move_uploaded_file($_FILES['priceguide']['tmp_name'], FILEREPOSITORY."$name.pdf"); if ($result == 1) echo "<p>File successfully uploaded.</p>"; else echo "<p>There was a problem uploading the file.</p>"; } #endIF } #endIF Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.