- 论坛徽章:
- 0
|
如题,但是我不用EOT输出,而直接用生JS运行就没问题,一加入PHP输出就报错。
[code]
print <<< EOT
<script language="javascript">
function getFolderList(folderspec){
var arr = new Array();
var fso = new ActiveXObject("Scripting.FileSystemObject");
doGetFolderList(arr, folderspec, fso);
return arr;
}
function doGetFolderList(arr, folderspec, fso){
var f, fc1, fc2, s, i;
f = fso.GetFolder(folderspec);
fc1 = new Enumerator(f.SubFolders);
for (;!fc1.atEnd(); fc1.moveNext()) {
i = arr.length;
arr[i] = new Array(2);
arr[i][0] = fc1.item();
arr[i][1] = "folder";
/* doGetFolderList(arr, fc1.item(), fso); 文件夹递归 */
}
fc2 = new Enumerator(f.files);
for (; !fc2.atEnd(); fc2.moveNext()) {
i = arr.length;
arr[i] = new Array(2);
arr[i][0] = fc2.item();
arr[i][1] = "file";
}
}
function test() {
var arr = getFolderList('D:\\usr\\www\\html');
for(var j=0;j<arr.length; j++) {
var o = document.createElement("OPTION");
o.value = arr[j][1];
o.text = arr[j][1] + "---" + arr[j][0];
document.all("sel").add(o);
}
}
</script>
<input type="button" value="get" onclick="test();">
<select id="sel" size="20" multiple="true">
<option>--------------------------------------------------------</option>
</select>
EOT;
code] |
|