Reputation: 4895
I need a way to find any devices that are currently plugged into a machine using PHP, the web application is ONLY run locally for a business.
I was thinking of maybe checking to see if a folder exists in a directory (for example: E:/DCIM/) and if there is an error the. It wouldn't exist, so check the next one.
Would be nice to get the devices name and storage capability though. I then need to use this information to upload any photos from the DCIM folder.
Upvotes: 0
Views: 216
Reputation: 336
What platform are you running on?
I would expect you're using Windows though...( From the E:). I found the following code you could use to help you with your task on http://php.net/manual/en/function.shell-exec.php
<?php
function GetVolumeLabel($drive) {
// Try to grab the volume name
if (preg_match('#Volume in drive [a-zA-Z]* is (.*)\n#i', shell_exec('dir '.$drive.':'), $m)) {
$volname = ' ('.$m[1].')';
} else {
$volname = '';
}
return $volname;
}
print GetVolumeLabel("c");
?>
Note: The regular expression assumes a english version of Windows is in use. modify it accordingly for a different localized copy of Windows. For a specific windows command to get all your required data, I would recommend:
wmic logicaldisk get volumename,size,caption
Overall, it seems you're forcing PHP to do something it isn't meant to do.
Upvotes: 1