Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 25th, 2006, 11:28 AM   #1
Master
Programmer
 
Master's Avatar
 
Join Date: Sep 2005
Location: GA
Posts: 99
Rep Power: 4 Master is on a distinguished road
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);
}

Last edited by big_k105; Sep 25th, 2006 at 11:40 AM. Reason: Added Code Tag
Master is offline   Reply With Quote
Old Sep 25th, 2006, 3:09 PM   #2
Booooze
Expert Programmer
 
Booooze's Avatar
 
Join Date: Mar 2006
Location: Igloo
Posts: 710
Rep Power: 3 Booooze is on a distinguished road
Send a message via MSN to Booooze
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.
Booooze is offline   Reply With Quote
Old Sep 26th, 2006, 8:21 AM   #3
Ghost
Man Bear Pig Hunter
 
Ghost's Avatar
 
Join Date: Jul 2005
Location: NorCal, USA
Posts: 295
Rep Power: 4 Ghost is on a distinguished road
I suggest looking toward a more advanced code, such as java, php, perl, c# or vb.net for those type of problems.
__________________
People who click "images" that end with .exe shouldn't have computers.
Ghost is offline   Reply With Quote
Old Sep 26th, 2006, 9:35 PM   #4
Master
Programmer
 
Master's Avatar
 
Join Date: Sep 2005
Location: GA
Posts: 99
Rep Power: 4 Master is on a distinguished road
Don't worry about it any more, i recode it in ASP.net with C#
Master is offline   Reply With Quote
Old Dec 1st, 2006, 6:06 PM   #5
mackenga
Professional Programmer
 
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 318
Rep Power: 4 mackenga is on a distinguished road
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...)
__________________
"I'm not a genius. Why do I have to suffer?"
mackenga is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
OnlineTextEditor.Com! Sane Show Off Your Open Source Projects 43 Jun 16th, 2006 9:55 AM
HTML page not reading external Javascript file aznluvsmc JavaScript and Client-Side Browser Scripting 9 Nov 21st, 2005 10:17 PM
After execution - Error cannot locate /Skin File? wchar Visual Basic 1 Mar 5th, 2005 10:04 PM
airport Log program using 3D linked List : problem reading from file gemini_shooter C++ 0 Mar 2nd, 2005 5:12 PM
Structure char field to a disk file ehab_aziz2001 C++ 0 Feb 10th, 2005 3:42 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:29 AM.

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