Glenn Mulno wrote:[color=blue]
> Is there a way to set a hyperlink so that it opens the newest file in a
> directory?[/color]
Yes, but not in the way you seem to be asking for. In the markup, you
could use a link like this:
<a href="/applicationperformance">Latest Application Performance Report</a>
When a user follows that link, the browser will send a request to the
server, and the server must then determine how to fulfil the request.
You cannot have the browser automatically append the date to the end of
the file URI for you, but even if you could, it wouldn't be reliable
anyway, since it would depend on the user's system having the correct
date set.
[color=blue]
> Why: I have a page that is a link to a daily set of reports. A new report
> gets output every single night with a new unique name like this:
> applicationperformance032520050100.doc[/color]
That's what makes ISO-8601 so useful. Instead of having a bunch of
numbers that don't seem to be in any logical order, it's easier if you
use YYYY-MM-DD hh:mm. eg. applicationperformance200503250100. That has
the advantage that sorting by file name also sorts by date. Anyway,
regardless of the odd date format you've chosen, you need to provide
some server side processing in order to map a request for
/applicationperformance to the latest file.
You could have applicationperformance.php (or .asp, .jsp or whatever
technology you want to use). You can use Multiviews (or an equivalent
for a non-Apache web server) so you don't have to include the file
extension in the URI.
Within this PHP file, the logic could work like this:
Get todays date.
Generate the filename for today.
(eg. applicationperformance + Month + Day + Year + Hour + Min + ".doc")
Check the file actually exists on the server.
ie. It could possibly be requested before today's report has been
generated and, if that is the case, yesterday's report should be
sent instead.
Either:
- Output the contents of the latest report file found.
- Send a 302 Found or 307 Temporary Redirect response to redirect the
user to the latest file.
[color=blue]
> I want to provide a link the "Yesterdays Report" without needing to go in
> and edit the link every morning.[/color]
This could be done in a similar way to the latest report above.
Alternatively, you could use server side processing to automatically
generate the appropriate file name.
eg.
<a href="/applicationperformance<?php date("mdYHi"); ?>.doc">Latest
Application Performance Report</a>
--
Lachlan Hunt
http://lachy.id.au/ http://GetFirefox.com/ Rediscover the Web
http://GetThunderbird.com/ Reclaim your Inbox