0

Is it possible to detect usb mouse,keyboard or flash drives when they are connected using php?

2
  • 1
    On a web server? Or on a web client? Or when running php without any webservers involved?
    – sarnold
    Jan 21, 2011 at 12:29
  • In PHP alone, no. But php can reach out to the OS e.g. via system() - that could work in conjunction with other programs, which perform the actual detection.
    – miku
    Jan 21, 2011 at 12:31

2 Answers 2

4

This is not really a matter of PHP, but of the underlying operating system. If the operating system detects it and makes the information readable for the user that runs the PHP script, you can "detect" devices using PHP.

4

Which side - server side or client side?

Server side: possible, although probably not a good idea. You would call OS specific functions or shell commands to access USB (e.g. shell_exec("lsusb -v"); ), and process the results.

Client side: No. PHP just works on server side.

Commandline PHP: same as Server side.

You are using the wrong tool for the job. Go back and use one more suited to the task.

2
  • 2
    Go back and use one more suited to the task.?
    – Geoffrey
    Jan 21, 2011 at 13:00
  • This was downvoted because of the directive to use a different solution, criticizing the author's choice (or maybe there is no choice), and not providing a sample "right tool for the job.'
    – Dennis
    Jul 6, 2023 at 0:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.