2

I am running Apache on a Linux server, I have an application mounted there that needs to read a directory from the enduser computer to copy some files, the problem is that the users work with Windows, all the app works fine but when trying the opendir command form PHP i get: failed to open dir: No such file or directory

I tried parsing the Windows path like this: - Verbose: "C:\path\to\files to copy" - With linux slashes: "C:/path/to/files to copy" - With double backslashes: "C:\\path\\to\\files to copy" - All of the above without spaces: "C:/path/to/files%20to%20copy"

None of these worked so far, they all give me the same Warning and never read the directory contents.

I'm running PHP 7.3 on Ubuntu 14 server.

$src = "C:\\path\\to\\files";
$dir = opendir($src); //this fails
var_dump(opendir($src)); //this outputs: bool(false)

At the end I need to use a recursive function on PHP to copy the contents of the directory to the server and keep the structure intact, but if the script is not able to open the directory nothing I do will work after that. Any suggestions?

Ektoer
  • 31
  • 2
  • If I'm reading this right you want to read a file from a remote users computer? This function was never designed to work in that way and that would be a big security hole. The only way for you to get that file is for the user to send it in a post request to you. – mic Jun 05 '19 at 21:50
  • Hi there. Can you give more details how you intend to copy the files? Coping a local directory via a browser isn't going to happen. Using a windows based path on a linux installation will not work either. – drclaw Jun 05 '19 at 21:50
  • Yes and no, the web-app should read the contents of a directory on the user terminal (Windows) to copy some files to the server to be used by the app. The user is in control of what to copy (they provide the path), I know i should use the $_FILES to upload to the server, but in this case the user uploads 2000+ files with a specific path that needs to be kept that way on the server... If what I'm reading from you comments is that this is just not possible, I would try another way to do this copy... – Ektoer Jun 05 '19 at 21:57
  • More on this: If I run the app on a Windows server (My computer with XAMPP installed) other computers connected to it using the app can make the upload via the copy command and it can read the directories with no problem. – Ektoer Jun 05 '19 at 21:58

0 Answers0