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 3 of 3
  1. #1
    New Coder
    Join Date
    May 2012
    Posts
    47
    Thanks
    3
    Thanked 0 Times in 0 Posts

    How to access and delete a file in javascript

    Hi ,

    My requirement is to access a file(in unix) from my javascript funtion.

    Let us assume , I have the following javascript function :

    function deleteFile()
    {

    var file = "dest.txt" ;



    }

    Now this file is inside a directory in my present directory.
    My present directory say, /home/myuser/
    The dest.txt file is under a directory my_dir in my present directory.

    How can I then access it as /home/myuser/my_dir/dest.txt and delete the same.

    Please help. Thanks

  • #2
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,899
    Thanks
    15
    Thanked 226 Times in 226 Posts
    Javascript doesn't allow access to the file system, for security reasons. It can only link to files of the .js extensions, or modify the code of the current page, and then only for the browser session.

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Flint, Michigan, USA
    Posts
    617
    Thanks
    1
    Thanked 20 Times in 20 Posts
    You should be able to do this using Visual Basic Script, but ONLY from within the Internet Explorer browser.

    I've done it on a Windows machine, but I don't have unix to test it. Sorry.


  •  

    Posting Permissions

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