open a folder with a button

Hello,

how can I open a folder with button.
What I did until now:

  1. I created a button -> type PHP
  2. added a code
$dir = "C:\Data\";
opendir($dir);

but I am getting an error:
Parse error: syntax error, unexpected ‘’ (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\Program Files (x86)\NetMake\v81\wwwroot\scriptcase\app\NSEOS\form_project\form_project_apl.php on line 1613

what does this error mean? Does soemone have a solution?

Try this:


$dir = "C:\\Data\\";
opendir($dir);

ok I am not getting errors, but folder doesn’t open

It looks like it’s working now.

But what do you mean by “open folder”?
The opendir doesn’t show a window nor anything visual. It just returns an object variable of type resource, which you can then use to do other operations (e.g. list files).

See the examples in the documentation:
http://php.net/manual/en/function.opendir.php

I literally just want to open a folder/directory C:\Data. The opendir function in PHP doesn’t make sense if it doesn’t open a folder/directory honestly speaking.

in C# its done this way!

System.Diagnostics.Process.Start("explorer", path);

How I can do that in scriptcase?

Yes, it does make sense.

You can’t just show Windows Explorer of a (remote) server to the user.
And because PHP runs in a (remote) server, you can’t use it to open/access a folder from the user’s computer.

What exactly are you trying to do?
Which folder you want to open?

I have a folder/directory on my C drive (C:\Data) and I just want to open it.

You can’t. The only way is to use an upload field as the browser will open the filedialog for you. But as Mamede says correctly, php runs on the server, there is no way php can open a dialog by itself.

sad. :frowning:
but thanks anyway