开发者

How to delete a file from physical directory with JavaScript (Windows/IE Only)?

I am dynamically generating an HTML开发者_运维技巧 file for the print option.

After the print window has been opened and the file printed, I want to remove the HTML file from the folder.

I need to do this with JavaScript. For this I am using the following code:

var myObject = new ActiveXObject("Scripting.FileSystemObject");
var myFolder = myObject.GetFile(strReportFilePath);
myFolder.Delete();`

But this only works in IE but not in Firefox, so how do I delete the file with a JavaScript function?


You can't. JavaScript is sandboxed. With IE, you are using ActiveX to do the dirty work.


I'm on the look out for just accessing files on the local files and failed to find a way that works cross-browser easily yet. However you might want to try signed Java applets which seemed to be a (though not so smooth) solution.

You also might want to keep track of this

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜