Connecting Tech Pros Worldwide Help | Site Map

Linked file properties

SmilingPolitely
Guest
 
Posts: n/a
#1: Jul 23 '05
I would like to have the properties of a linked file appear on the page
linking to it, so that the user can see the date last modified and file
size.

I.E.

<a href="filename>Click here to download file: size <script to insert
file size>, last modified on <script to insert date last modified></a>

Is this possible using only javascript. I don't have access to
PHP/ASP/anything else useful on the server. Perhaps you might know of
an alternate way to achieve my aims?

Any help is appreciated.
Martin Honnen
Guest
 
Posts: n/a
#2: Jul 23 '05

re: Linked file properties




SmilingPolitely wrote:

[color=blue]
> <a href="filename>Click here to download file: size <script to insert
> file size>, last modified on <script to insert date last modified></a>
>
> Is this possible using only javascript. I don't have access to
> PHP/ASP/anything else useful on the server. Perhaps you might know of
> an alternate way to achieve my aims?[/color]

It is certainly possible using JavaScript on the server. If you do not
have server-side scripting available then if you consider those infos
important for your users you have to insert them by hand in the markup.
If the infos are optional you could consider using client-side script to
make HTTP HEAD requests and try to read out the info from the HTTP
response headers:
<http://home.arcor.de/martin.honnen/javascript/200504/test2005041101.html>

Note that the example is meant to be a proof of concept, I have tested
that it works with Mozilla and with IE on Windows but I know that at
least current beta releases of Opera have some support for
XMLHttpRequest but do not support methods to get the response headers.
And I think others have reported that some Safari versions do not
support HTTP HEAD requests.
So the code in the example would need to be improved to prevent or to at
least handle errors occuring in those browsers.



--

Martin Honnen
http://JavaScript.FAQTs.com/
SmilingPolitely
Guest
 
Posts: n/a
#3: Jul 23 '05

re: Linked file properties


Martin Honnen wrote:[color=blue]
>
>
> SmilingPolitely wrote:
>
>[color=green]
>> <a href="filename>Click here to download file: size <script to insert
>> file size>, last modified on <script to insert date last modified></a>
>>
>> Is this possible using only javascript. I don't have access to
>> PHP/ASP/anything else useful on the server. Perhaps you might know of
>> an alternate way to achieve my aims?[/color]
>
>
> It is certainly possible using JavaScript on the server. If you do not
> have server-side scripting available then if you consider those infos
> important for your users you have to insert them by hand in the markup.
> If the infos are optional you could consider using client-side script to
> make HTTP HEAD requests and try to read out the info from the HTTP
> response headers:
> <http://home.arcor.de/martin.honnen/javascript/200504/test2005041101.html>
>
> Note that the example is meant to be a proof of concept, I have tested
> that it works with Mozilla and with IE on Windows but I know that at
> least current beta releases of Opera have some support for
> XMLHttpRequest but do not support methods to get the response headers.
> And I think others have reported that some Safari versions do not
> support HTTP HEAD requests.
> So the code in the example would need to be improved to prevent or to at
> least handle errors occuring in those browsers.
>
>
>[/color]
Thanks very much Martin.... works like a charm
Closed Thread