Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Sep 2005
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Read and Write Files

    Hi all,

    one question ... Exist in Javascript the option to Write and read files ?

    something like:

    Code:
    if user enter here then write 1 on example.txt
    and/or:

    Code:
    if user enter here then read example.txt
    ?

    Bye,

    Neo

  • #2
    Regular Coder martin_narg's Avatar
    Join Date
    Jul 2002
    Location
    Chamonix, France
    Posts
    600
    Thanks
    1
    Thanked 3 Times in 3 Posts
    You can use the FileSystemObject to read/write files in Internet Explorer and there is a Mozilla alternative, but there will be nasty security warnings popping up at best, and this process will be totally blocked at worst by the user's browser.

    If the application is to be run localy on a windows machine, you can use an .hta file or somesuch. If possible - try to do this server-side.
    "Cos it's strange isn't it. You stand in the middle of a library and go 'Aaaaaaaaaaaaaaaaggggggghhhhhhh!'
    and everybody just stares at you. But you do the same in an aeroplane, and everybody joins in."
    -Tommy Cooper

  • #3
    New Coder
    Join Date
    Sep 2005
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hi all,

    hmmm first of all thanks for the feedback (y)))))

    but i have a problem ... im new in javascript programmation so i need to ask you one more thing ... could you make a sample of a FileSystemObject for i learn how that works please? Thanks .... Don't need many options something for i test and see how that works ... and also if you want your SiteLogo for i put on my afiliates sites (I like ask for help but i like also put a "linkback" for who help me)

    Bye,
    Neo

    PS: or as alternative if you know how we create a .hta when we are running with a IIS server and Win 2003 as OS.
    Last edited by Sysop_Neo; 09-24-2005 at 02:34 PM.

  • #4
    Regular Coder martin_narg's Avatar
    Join Date
    Jul 2002
    Location
    Chamonix, France
    Posts
    600
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Use ASP/VBScript:

    Writing a file:
    Code:
    Dim fso, MyFile
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set MyFile = fso.CreateTextFile("c:\testfile.txt", True)
    MyFile.WriteLine("This is a test.")
    MyFile.Close
    Reading a file:
    Code:
    Const ForReading = 1
    Dim fso, f, strContents
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set f = fso.OpenTextFile("c:\testfile.txt", ForReading)
    strContents = f.ReadAll
    FileSystemObject Reference

    But you'd be better off using a database to store data in.

    Hope this helps.

    m_n
    "Cos it's strange isn't it. You stand in the middle of a library and go 'Aaaaaaaaaaaaaaaaggggggghhhhhhh!'
    and everybody just stares at you. But you do the same in an aeroplane, and everybody joins in."
    -Tommy Cooper

  • #5
    New Coder
    Join Date
    Sep 2005
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks, i think so ...


    bye (b)

    Neo
    Last edited by Sysop_Neo; 09-24-2005 at 07:37 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •