Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   JavaScript and Client-Side Browser Scripting (http://www.programmingforums.org/forum23.html)
-   -   How to delete file in JavaScript (http://www.programmingforums.org/showthread.php?t=11392)

Master Sep 25th, 2006 10:28 AM

How to delete file in JavaScript
 
I did this but it does not work

:

function DeleteFile(filename)
{
    var fso = new ActiveXObject("Scripting.FileSystemObject");
    fso.DeleteFile(filename, true);
}


Booooze Sep 25th, 2006 2:09 PM

Couldn't tell you about the code, but Javascript isn't really made for modifying file system content. It can be done, but it is probably considered malicous code these days. If the code is correct, consider looking into whether or not your browser is actually letting the code run.

Ghost Sep 26th, 2006 7:21 AM

I suggest looking toward a more advanced code, such as java, php, perl, c# or vb.net for those type of problems.

Master Sep 26th, 2006 8:35 PM

Don't worry about it any more, i recode it in ASP.net with C#

mackenga Dec 1st, 2006 5:06 PM

Shudder. What do you mean, a more 'advanced code'? JavaScript might be a little clunky but there is nothing advanced about deleting a file.

Booooze probably has the right answer if this JavaScript code is trying to run inside a browser. But if it was trying to delete a file at the server side, then it's not malicious and should have worked; runat="Server" in the SCRIPT tag would avoid having the code sent to the client, which should refuse to instantiate the FileSystemObject for security reasons.

As for moving to ASP.NET just for this functionality - do you have any idea what you've added to the footprint of your server-side script for the sake of an easy file delete?!

Ah well, I suppose you get other advantages that way too. Ho hum.

(Trying not to rant...)


All times are GMT -5. The time now is 3:57 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC