Connecting Tech Pros Worldwide Help | Site Map

Linked file properties

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

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, 08:07 PM
SmilingPolitely
Guest
 
Posts: n/a

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Function not defined when js in external file gregp1 answers 7 September 19th, 2007 11:29 AM
Link the FE to the BE using Code and Path/File ApexData@gmail.com answers 7 March 19th, 2007 04:35 AM
Random Compilation Error - Access Denied to my linked assemblies Raterus answers 5 November 18th, 2005 09:52 AM
Access file system with HTML Paul Ponting answers 8 July 20th, 2005 06:07 PM