Get the file path from portable device in windows

63 Views Asked by At

I wrote a php script to copy files from an iPhone connected by USB.

The issue is that I need a path for the scandir function and because the iPhone is seen as a portable device the path I get from the explorer is something like "This computer\Apple iphone\Internal storage\DCIM" and I would need something like "C:/something/"

How can I get the portable device path to reach the iphone content ?

1

There are 1 best solutions below

0
Konstantin Pereiaslov On

You would need to work with Windows Portable Devices API.

iPhone in Windows is not mounted as a part of the filesystem, so it can not be accessed by normal php filesystem functions.

Microsoft provides documentation here for C++: https://learn.microsoft.com/en-us/windows/win32/wpd_sdk/programming-guide

It should be possible to access these functions from PHP using FFI: https://www.php.net/manual/en/class.ffi.php but this is far from a trivial task, as you'd need to create bindings for the C++ library.