Reputation: 127
I want to add names of files of a specific folder to an JS's array, but nothing happens:
var pics = new Array();
var x;
var fs = new ActiveXObject("Scripting.FileSystemObject");
alert('x');
var fo = fs.GetFolder(Server.MapPath("C:\wamp\www\newsite\ErfanGhiasiPanel\Slider Images"));
for (x in fo.files){
pics.push(x.Name);
}
For instance, whet I insert an
alert('something')
after var fs = new ActiveXObject... or next lines, it won't appear. What you guys think?
Thank you
Upvotes: 0
Views: 5920
Reputation: 175796
Assuming JScript + Classic ASP due to the MapPath
(which you dont need in your case) you need to escape the path string;
var pics = [];
var fs = new ActiveXObject("Scripting.FileSystemObject");
var fo = new Enumerator(fs.GetFolder("C:\\wamp\\www\\newsite\\ErfanGhiasiPanel\\Slider Images").Files);
for (; !fo.atEnd(); fo.moveNext()) {
pics.push(fo.item(0).Name)
}
Upvotes: 1