Jorge Garnica
Jorge Garnica

Reputation: 1256

Open Windows folder from PHP

I need just to open a windows explorer from PHP. I tried this: https://github.com/cztomczak/phpdesktop but doesn't work. I just want to press a button or anything and open a window from windows NOT BROWSE FILE TO UPLOAD, just open a window THANK YOU.

Upvotes: 1

Views: 14228

Answers (3)

Imanuel
Imanuel

Reputation: 3667

Usually, PHP runs on a server and dynamically prepares an HTML document which is then displayed by your browser.
In this case, what you want to do is not possible.

If you run PHP on your windows machinge as a scripting language instead, this is possible. This is the code you would need:

chdir($path);
exec("start .");

Note that PHP's chdir function might have trouble navigating to long directory paths. E.G. "C:\Program Files (x86)\Development Server\binaries\php\php713vc14x86x200518222354". If your paths go many folders deep then consider using something like this.

NavigateToDirectory($Path);
function NavigateToDirectory($Directory){
    $Directory = explode('\\', $Directory);
    for($i=0; $i<count($Directory); $i++)
        if(is_dir($Directory[$i]))
            chdir($Directory[$i]);
}

Upvotes: 2

The EasyLearn Academy
The EasyLearn Academy

Reputation: 927

$path = "G:\\android_batch_8";
exec("EXPLORER /E,$path");

i have used above code and it is working perfectly but one problem is how open this folder in maximized window?

Upvotes: 2

Anshul
Anshul

Reputation: 103

Php is server side Scripting language. it cannot perform any action on client side computer like opening explorer window.It can only store some cookies on client side that's it. you can use this

<input type="file"></input>

this is html which is used to open explore window to upload files.

Upvotes: -3

Related Questions