#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2002
    Posts
    10
    Rep Power
    0

    Is it possible to write to a file using JavaScript?


    I'm guessing probably no, I can't write to (append) files on the web server using JavaScript.

    Thing is, I don't know and that's why I asked

    Anyone care to share info?

    Thanks in advance.
  2. #2
  3. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Apr 2000
    Posts
    1,058
    Rep Power
    22
    javascript that is exected on the client-side is going to have the permission of the average client connecting to the server - read only.

    wdn2k
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2002
    Posts
    10
    Rep Power
    0
    what about on the server side i.e. the function call (of whatever it may be) is done on the server side.

    is there such a function?
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2002
    Location
    Seattle WA
    Posts
    863
    Rep Power
    14
    Perl, php, asp, dozens of others...pick your poison. Many (though not all) have full i/o functions/operations. So basically, you need to chose a server side scripting language...
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2002
    Posts
    10
    Rep Power
    0
    yeah i know im an avid php programmer myself.

    i lost touch with JS after years of experience with it and how it has the innate ability to be really uncooperative. (I just HATE that yellow exclamation mark in IE)...

    So what I need to know is if there are any functions of JS to do i/o operations.

    Why? I got this damned school project on HTML and JS. It's stupid, I know. You know how it is, learnt it all, but its for nothing since you got no certification etc...

    I thought i wanted to do something big by creating a guestbook driven by JS..

    Well, hope help comes. Or if anybody is confident enough to actually tell me that no, there is no such thing!

  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2002
    Posts
    10
    Rep Power
    0
    Or have I REALLY lost touch with JS that I somehow forgot that JS is a clientside-only language? (i.e. it "messes" with just the user's browser)
  12. #7
  13. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Apr 2000
    Posts
    1,058
    Rep Power
    22
    I thought I already did.

    Javascript executed on the client will only have read access to the server, so no, in most cases it couldn't write to the server. Of course, nothing is absolute in this world, and if you really wanted to you could make it possible for users to delete files off the server without any special permission.

    The easy answer is no, you're not going to be making a guestbook with only HTML and javascript.


    wdn2k
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2002
    Location
    Seattle WA
    Posts
    863
    Rep Power
    14
    Incidentally, in explorer, you can write/read/alter files with javascript. Regardless of internet settings, it generates a security warning (obviously), but it can be done. Look up "FileSystemObject" on the MSDN.

    Code:
    var fso;
    fso = new ActiveXObject("Scripting.FileSystemObject");
    fso.write(...);
    Or something like that. Client side only, of course.
  16. #9
  17. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2002
    Posts
    10
    Rep Power
    0
    let me get that straight. so im using javascript to call that activex object/function that actually does the actual writing? bah...i can't use activex i think...isn't covered in the damned syllabus...but hey i'll look it up a little, thanks for the info anyway..

IMN logo majestic logo threadwatch logo seochat tools logo