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 4 of 4
  1. #1
    New Coder
    Join Date
    Mar 2012
    Posts
    52
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Copy and paste in Windows using Javascript

    Hi,

    I am wondering, is there any method that can copy a file(.pdf) from server and paste it in the local drive while the file(.pdf) in the local drive is reading by users ?

    P/S : In Windows, the users are not allow to edit or replace the file if it's being read.

    Requirements : The users must read the file in local drive after copy from the server.

    2 methods been tried :

    1. I tried the method which make the javascript to close the browser(IE) first, then copy and replace the file but after the browser is close, everything stopped.

    2. Then, I also tried to reopen the file from server first, then only I copy the file from server and replace the local file again but the problem exists again. Even though the local file is closed and file from server is open, the system just doesn't allow me to copy and replace the local file. Why ?

    Can anyone give me some suggestion or advice please ? Really need help on this issue.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,441
    Thanks
    76
    Thanked 4,372 Times in 4,337 Posts
    You answered your own question:
    In Windows, the users are not allow to edit or replace the file if it's being read.
    So the best you could do would be to get *ANOTHER* copy of the file and save it as *ANOTHER* file name.

    And yes, you *could* do this in MSIE if you turn off some of the security settings. You can write files from JavaScript in MSIE *IF* the security settings are low enough to allow it. But it's a really really bad idea to do so. It might be viable in an inTRAnet situation (e.g, your company could require you to allow unsafe scripting when accessing certain internal sites. But it would naver work for an inTERnet system.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,639
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Quote Originally Posted by Old Pedant View Post
    And yes, you *could* do this in MSIE if you turn off some of the security settings. You can write files from JavaScript in MSIE *IF* the security settings are low enough to allow it.
    I thought Microsoft fixed that in IE7 because they didn't want people blaming them for the gazillion viruses that would be allowed access to the computer when the settings are that low. Microsoft don't have enough trillions of dollars to coverall the payouts that would result from people's own stupidity and so disabled the ability to turn off such stupid settings. That's why some intranets had to stick with IE6.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #4
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,335
    Thanks
    11
    Thanked 588 Times in 569 Posts
    what is the point of the complex procedure you outline?

    just serve them the file as an attachment (content-disposition header). it will be copied to the temp folder, where it will eventually be automatically deleted.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%


  •  

    Posting Permissions

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