Unable to access enumeratedir in a web page

Issue #198 resolved
Former user created an issue

I´ve used the scripting language DWScript for a couple of days and of course have some problems... Firstly I want to say "Thank you." to some registered users and some threads about DWScript, they´ve helped me very much... Now I´m stuck with the dwsfilefunction "enumeratedir": how use it right in a script file which must be accessible from the web?

Here´s the code I´ve used:

var myfilelist: array of string;
var i: integer;

begin
  myfilelist:=enumeratedir('/test', '*.*', true);
  for i:=0 to length(myfilelist)-1 do
  begin
    println(myfilelist[i]);
  end;
end;

EDIT: Also I´ve problems with the first parameter: The console says it´s an unauthorized file path.

EDIT2: Now the exact error message:

Runtime Error: Unauthorized file path: "/test"

EDIT3: I´m using Windows 10 64-bit, but a modified file path isn´t working too:

Runtime Error: Unauthorized file path: "C:\DWSciptWebServer\www\test\"

By the way, if I specify a file as a filename (e.g. "Test.txt"), then there´s no error message anymore, but I know it isn´t a directory...

I´d be happy of a fast reply and good help. Thanks

Comments (2)

  1. Eric Grange repo owner

    By default in the sample webserver, only the www path is open to scripts, if you want to allow other paths, you have to adjust the options.json file, DWScript / WorkPaths setting, f.i. in your case it could be (with the error in folder name replicated)

    {
        "Service" : {
            ...
        },
        "Server" : {
           "WWWPath" : "C:\\DWSciptWebServer\\www",
           ...
        },
        "DWScript" : {
            "WorkPaths": ["%www%", "C:\\Test", "D:\\other\\path"],
            ...
       }
    }
    

  2. Log in to comment