Click here to Skip to main content
15,881,204 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,
I am trying to download a file through Java Script. The file path I am getting from code behind. When I am clicking a ASP.Net Button onClientClick it should hit the java Script function which is client side, and save a specific path on the local system.

Below is the Code

onClientClick event below function is calling
function WriteFile() {
var fso = new ActiveXObject("Scripting.FileSystemObject");
var fh = fso.CreateTextFile("c:\\Test.bmp", true);
fh.WriteLine("Some text goes here...");
fh.Close();
}

but it is not happening.



Please help.





Thanks to All.

Indrajit Dasgupta

What I have tried:

download a file using javaScript
Posted
Updated 13-Jun-16 22:29pm
v2
Comments
phil.o 14-Jun-16 3:12am    
What have you tried?
IndrajitDasgupat 14-Jun-16 3:25am    
on ClientClick event below function is calling
function WriteFile() {
var fso = new ActiveXObject("Scripting.FileSystemObject");
var fh = fso.CreateTextFile("c:\\Test.bmp", true);
fh.WriteLine("Some text goes here...");
fh.Close();
}

but it is not happening.
phil.o 14-Jun-16 3:25am    
Please use the green "Improve question" button, and put your code there.
Code in comments is hardly readable.
IndrajitDasgupat 14-Jun-16 3:31am    
ok

1 solution

This article could sched a light on your problem:
FileSystemObject Basics[^]
Especially the part:
"Because using the FSO on the client side may provide potentially unwelcome access to a client's local file system, you should use it only in scripts executed on the server side. Internet Explorer default security settings do not allow client-side use of the FileSystemObject object. Overriding those defaults could subject a local computer to unwelcome access to the file system, which could result in total destruction of the file system's integrity, causing loss of data, or worse."
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900