Connecting Tech Pros Worldwide Help | Site Map

Linked file properties

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 23rd, 2005, 07:07 PM
SmilingPolitely
Guest
 
Posts: n/a
Default Linked file properties

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.

  #2  
Old July 23rd, 2005, 07:07 PM
Martin Honnen
Guest
 
Posts: n/a
Default 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/
  #3  
Old July 23rd, 2005, 07:07 PM
SmilingPolitely
Guest
 
Posts: n/a
Default 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
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.