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.

MultiplyByZer0
  • 6,302
  • 3
  • 32
  • 48
Kevin
  • 217
  • 6
  • 19
  • 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? – StackExchange What The Heck Dec 23 '13 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? – Dagg Nabbit Dec 23 '13 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... – Dagg Nabbit Dec 23 '13 at 20:57
  • There is also: http://stackoverflow.com/questions/20525822/javascript-copy-file – StackExchange What The Heck Dec 23 '13 at 20:59
  • [FileSystemObject MSDN](http://msdn.microsoft.com/en-us/library/6kxy1a51(v=vs.84).aspx) – Givi Dec 23 '13 at 21:02
  • @yochannah I think there's a way to do this in Moz with XPCOM, but I'm not seeing it in any of these answers. Without feedback from OP about specific use case, I think this question is unclear, CVing for now. – Dagg Nabbit Dec 23 '13 at 21:03
  • [JavaScript: ActiveXObject in Firefox or Chrome (not IE!)](http://stackoverflow.com/questions/7022568/javascript-activexobject-in-firefox-or-chrome-not-ie) – Givi Dec 23 '13 at 21:24

1 Answers1

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.

Mehran Hatami
  • 12,723
  • 6
  • 28
  • 35
  • I am building an internal and very specific application here with limited resources. I think going with php would be good idea. – Kevin Dec 23 '13 at 21:49
  • yes it could be, with php you could have all kinds of access on your server machine files not on your client's. – Mehran Hatami Dec 23 '13 at 22:01