3

I need to put image file from one directory to another with click of a button. I already have code for this-

<input type="button" name="button" value="Copy image to another folder2 "  onClick="moveFile('c:\path1', c:\path2\)"/> 

<script>    
    function movefile(path1, path2) {
        var myObject, f;
        f = new ActiveXObject("Scripting.FileSystemObject");                                          
        f.Copyfile(path1,path2)
    }
</script>

But the problem is ActiveXobject only works for IE and not FF and chrome. Is there any any other way in js or any function in js that I can use which would work on all 3 browsers.

7
  • 1
    At a guess, allowing browsers to control system files is a security vulnerability and secure browsers might not permit it. Out of curiousity, which IE versions did you test this in? Commented Dec 23, 2013 at 20:53
  • How are you running this? This doesn't work from a remote site, does it? What's your use case (who is supposed to be the end-user)? Also, didn't you forget the braces around your function declaration? Commented Dec 23, 2013 at 20:53
  • @yochannah, I think that question has been asked here before and gotten more thorough answers, but I can't find it right now... Commented Dec 23, 2013 at 20:57
  • There is also: stackoverflow.com/questions/20525822/javascript-copy-file Commented Dec 23, 2013 at 20:59
  • FileSystemObject MSDN Commented Dec 23, 2013 at 21:02

1 Answer 1

2

as @yochannah has said allowing browsers to control system files is a security vulnerability, so that this is not so much accepted to do so.

but there are still some ways to go through these kinds of issues, which are different for each browser.

firefox and chrome let you to create a kind of extension or addon or plugin to do what you want, and your clients have to install it on their browsers, in fact, to do so your client have to admit that your plugin has the permission to change the files on the client machine.

check this link for How to develop a Firefox extension

and this one for Building a Chrome Extension

If I were you I would change my view and then I would design my solution again without browsers needing to be open for these kinds of security vulnerabilities. for instance Cloud based solutions are the best way to manage your clients files on their own Cloud accounts without needing you to have access to the client machine.

Sign up to request clarification or add additional context in comments.

2 Comments

I am building an internal and very specific application here with limited resources. I think going with php would be good idea.
yes it could be, with php you could have all kinds of access on your server machine files not on your client's.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.