Open windows explorer using PHP and/or JS

Asked

Viewed 1,585 times

1

Good morning to all.

It is possible to open Windows Explorer, on the client’s station in a certain network folder (windows sharing) either with PHP and/or JS itself.

I’ve tried it with php exec() and JS window.open(faithful:///) but without success.

The application is running on linux on the same network of client stations.

  • I believe this depends much more on browser security permissions than on language.

  • My tests were done in both firefox and Chrome, which are the most used here by my users.

  • In general the explore allows this

2 answers

3

You can open Windows Explorer using PHP?

No! PHP is a language that runs on server-side; in a general context Voce will not be able to interact with native resources in the client-side, ie in the user’s browser;

You can open Windows Explorer using Javascript?

Using Internet Explorer (probably this is not possible with other browsers), you can use some Activex features, but I only tested it with HTML saved on the machine itself; using something like:

<script type="text/javascript">
   window.open("nomeDoArquivo.html", "NomeDaNovaJanela");
</script>

I don’t know the context to which you need to use this solution, but from a security point of view this is not advisable at all; apart from the fact that most browsers do not allow actions like this, you will face various restrictions with anti-softwareviruses that consider actions as such a threat;

I recommend thinking of another approach to solve your problem; Manipulating client directories doesn’t seem to me to be an approach to web-based solutions, for the simple fact that you can’t guarantee that a particular directory exists in the client;

1

Can be done by Javascript and Activex.

<script type="text/javascript">
        function abrirPrograma()
        {
            var shell = new ActiveXObject("WScript.Shell");
            var fileLeft = "\"D:\\Caminho\\para\\o\\arquivo\"";
            var fileRight= "\"D:\\Caminho\\para\\o\\arquivo2\"";
            shell.Run(fileLeft + " " + fileRight);
        }
        </script>

To open use a link/button/etc... specifying the function:

<a href="abrirPrograma()">Abrir Programa</a>
  • From what I read this solution will only work in IE, which would not be the case. Activexobject is only supported by IE. In other browsers the error "Activexobject is not defined".

  • Yes, but I only know solutions involving IE. for Firefox will be with href file: and Chrome but it works badly.

  • thanks for the help, but looking for something crossbrowser, even the file: is not working because from what I read both Firefox and Chrome are blocking.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.