...

View Full Version : Copy and paste in Windows using Javascript



Jian0203
03-21-2012, 03:24 AM
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.

Old Pedant
03-21-2012, 03:50 AM
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.

felgall
03-21-2012, 09:02 AM
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.

rnd me
03-21-2012, 11:44 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum