JavaScript - Create New Folder through Javascript

Asked By Lokesh M on 04-Jul-08 11:43 PM
Hi, I have a javascript code which creates folder called new in my local c drive. but I know the static ip address of remote machine, i would like to specify this ip address and i would like to create new folder in their machine when i run the javascript code from my machine.. I might need to handle networking and security issues also... Please help me... Thanks Lokesh

Try this code

Sagar P replied to Lokesh M on 04-Jul-08 11:58 PM

var s = "C:/" +dirCreated[i];

sFolderPath = s;
var oShell = new ActiveXObject("Scripting.FileSystemObject");

  if (! oShell.FolderExists(sFolderPath) )
      oShell.CreateFolder(sFolderPath)
  else
       alert("THIS FOLDER ALREADY EXISTS")

OR you can do it like;

var oShell = new ActiveXObject("Scripting.FileSystemObject");

  if (! oShell.FolderExists("C:\Test") )
      oShell.CreateFolder("C:\Test")
  else
       alert("THIS FOLDER ALREADY EXISTS")

Go thr this link to know more about FileSystemObject (FSO) object model

http://www.yaldex.com/wjscript/sgProgrammingFileSystemObject.htm

Best Luck!!!!!!!!!!!!!!!!
Sujit.

Try like this

santhosh kumar replied to Lokesh M on 05-Jul-08 01:06 AM
    Hi,

  
function CreateFolder()
{
var fso, fldr;
fso = new ActiveXObject("Scripting.FileSystemObject");
fldr = fso.CreateFolder("C:\\MyTest");
Response.Write("Created folder: " + fldr.Name);
}

   Regards,
   Santhosh

remote machine folder creation

Lokesh M replied to santhosh kumar on 05-Jul-08 01:30 AM
Here my concept is different, I'm able to create folder in my local machine.. But i'm looking to create folder in remote machine when i run the javascript code from my machine... 
Hi,
sri sri replied to Lokesh M on 05-Jul-08 02:39 AM
Hi,
Javascript will run in the client only.
you have to try Ajax to create a folder in the server