Deleting a File in JavaScript

Discussion in 'JavaScript' started by ProductivePC, Oct 28, 2006.

  1. #1
    I am attempting to check to see if a file exists in a child uploads directory from the parent directory the script is in however the script does not seem to want to create a new object. I run into an issue on var fso = new. Any suggestions?
    How would I get this to work?
    Is there a better or easier way to delete a file if it exists?
    Thanks for any help.

    
    <script language="JavaScript">
    <!--
    function delfile()
      {
       var readfile="<?php=$readfile?>";
       var fso = new ActiveXObject("Scripting.FileSystemObject");
       fileBool = fso.FileExists("uploads/" + readfile);
       if(fileBool)
         {
     document.write("Test-fileBool");
     fso.DeleteFile("uploads/" + readfile,true);
         }
      }
    //-->
    </script>
    
    Code (markup):
     
    ProductivePC, Oct 28, 2006 IP
  2. ProductivePC

    ProductivePC Peon

    Messages:
    362
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Nevermind,

    I asked in another forum and found out this is JScript, not JavaScript and it will only work in IE. That being the case, I am looking for a different method. It also uses ActiveX apparently and in IE7 there is a setting to turn ActiveX on or off.
     
    ProductivePC, Oct 30, 2006 IP