![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Sep 2005
Location: GA
Posts: 99
Rep Power: 3
![]() |
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 10:40 AM. Reason: Added Code Tag |
|
|
|
|
|
#2 |
|
Expert Programmer
|
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.
|
|
|
|
|
|
#3 |
|
Man Bear Pig Hunter
Join Date: Jul 2005
Location: NorCal, USA
Posts: 290
Rep Power: 4
![]() |
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. |
|
|
|
|
|
#4 |
|
Programmer
Join Date: Sep 2005
Location: GA
Posts: 99
Rep Power: 3
![]() |
Don't worry about it any more, i recode it in ASP.net with C#
|
|
|
|
|
|
#5 |
|
Professional Programmer
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 314
Rep Power: 4
![]() |
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?" |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| OnlineTextEditor.Com! | Sane | Show Off Your Open Source Projects | 43 | Jun 16th, 2006 8:55 AM |
| HTML page not reading external Javascript file | aznluvsmc | JavaScript and Client-Side Browser Scripting | 9 | Nov 21st, 2005 9:17 PM |
| After execution - Error cannot locate /Skin File? | wchar | Visual Basic | 1 | Mar 5th, 2005 9:04 PM |
| airport Log program using 3D linked List : problem reading from file | gemini_shooter | C++ | 0 | Mar 2nd, 2005 4:12 PM |
| Structure char field to a disk file | ehab_aziz2001 | C++ | 0 | Feb 10th, 2005 2:42 PM |