Forum Moderators: open

Message Too Old, No Replies

filesystem options in javascript?

is it possbile?

         

sebbothebutcher

11:26 pm on Apr 16, 2004 (gmt 0)

10+ Year Member



i have a question and i fear the answer is "no!" but i will try. is there any way in javascript to check wether a file is existing or not?
please write back!

Bernard Marx

11:30 pm on Apr 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do you mean on the users PC?

Then 'yes', but this behaviour will cause an alert (if it runs at all)

search: JScript fileSystemObject

sebbothebutcher

9:51 am on Apr 17, 2004 (gmt 0)

10+ Year Member



no... not exactly! i mean on the server! wether there is any possibility to check if a file is existing on the server!
is this possible?

Rambo Tribble

2:03 pm on Apr 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't think you will be able to test for a file without trying to load it. JavaScript is pretty limited in the permissions it has for file handling. You might try loading the file into a frame that has visibility:hidden, and thereby test for its existence.

adni18

2:05 pm on Apr 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is the file that will always have the same content and be in the same folder and will only have the file if they install it from an installation that you made and can further edit?

If so, this is a pretty crude way to do it:

1) Put a

.txt
in the same folder as the file and call it 'fileyes_DO_NOT_DELETE_THIS.txt' or something like that

2) In the txt file, type 'TRUE' or something to show that it is 'positive'

3) You can change the stuff in here, but this goes in your HTML doc:

<HEAD> <SCRIPT langauge="JavaScript"> function fileEyes() { if(window.frames.document.body.innerHTML!='TRUE')\\Is the .txt file there?{alert('You do have the file')}else{alert('You do not have our file.')}\\otherwise alert them } </SCRIPT> </HEAD> <BODY> <IFRAME SRC="S:\MyFile\file_eyes_DO_NOT_DELETE_THIS.txt" name='trueorfalse' style="display:none">Your browser cannot identify iframes. Please <a href="http://www.microsoft.com/windows/ie/downloads/critical/ie6sp1/download.asp">download one that can</a> </IFRAME> <br> <button onClick="fileEyes()">Do I have the File?</button>

sebbothebutcher

10:47 pm on Apr 17, 2004 (gmt 0)

10+ Year Member



well... what i actually wanted to know, if there is a simple javascript to check, wether a file exists.
this file is in the same directory!

Rambo Tribble

1:46 am on Apr 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



JavaScript is prevented from accessing a file system except to request a file.

sebbothebutcher

6:41 pm on Apr 19, 2004 (gmt 0)

10+ Year Member



okay i gave up and read a PHP tutorial... seems to be a piece of cake if using PHP!
gotta lern it now...

Bernard Marx

8:57 pm on Apr 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's not so hard with ASP / JScript either.
There, you can use the FSO just like you would on the local filesystem.

..but who can argue with PHP either.