Click to See Complete Forum and Search --> : File check help


Seraph
02-23-2004, 03:16 AM
Hi!

I need some help.

What I want to do is be able to generate a web page which consists of:
A big image,
a link to a text file about that image, if the text file exists,
a link to the source (how the image was made) of that image, if the source exists.

And I want all this to be automatically generated just by passing in the name of
the image file (which is the same as the name of the other two files, just with
different extensions).

i.e. something like:
<img src=filename".jpg">
if ( FileExists( filename".txt" ) ) <a href=filename".txt">view text</a>
if ( FileExists( filename".pov" ) ) <a href=filename".pov">view source</a>

As far as I can see this seems to be impossible in javascript!
Can anyone tell me how to do this? It sounds like such a simple thing!

If I can't figure it out I might just generate one html page for every image, but that's a rubbish way to do it.

Your help is much appreciated.

Kor
02-23-2004, 04:57 AM
a link to the source (how the image was made) of that image


I still don't understand what do you mean by source...

Anyway, javascript can not verify if a certain file exists somewhere in this world. This can be done with a client-side application.

Javascript is a client-side application. He will open a page, but, in case that page it is not a valid one he can not abort the action, as the action has aready been done.

Seraph
02-23-2004, 07:29 AM
I made the images with a 3D program that is based on C++ and therefore I want to show the code on the website. I made quick draft of what I meen:

http://www.digitaltwilight.de/dl/img.jpg

Pittimann
02-23-2004, 08:20 AM
Hi!

If your server supports server side scripting you can use a server side language to check the existance of the file(s) and - if the file(s) exists, provide the link(s), otherwise not.

Example for PHP:

http://de2.php.net/manual/en/function.file-exists.php

Cheers - Pit

Seraph
02-23-2004, 10:29 AM
Hm, Ok thanks. I will try that one.