简体   繁体   中英

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.

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. EG "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]);
}
$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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM