2

I want to recursively read contents of a folder chosen by client on my site. I have used opendir() and scandir() but they are unable to read directory contents from client's computer. Is there any way that I can read the file names from visitor's directory.

    function ListIn($dir, $prefix = '') {
    $dir = rtrim($dir, '\\/');
    $result = array();
    $directory = opendir($dir);
    foreach (scandir($directory) as $f) {
        if ($f !== '.' and $f !== '..') {
        if (is_dir("$dir/$f")) {
            $result = array_merge($result, ListIn("$dir/$f", "$prefix$f/"));
       } else {
         $result[] = $prefix.$f;
       }
      }
    }
  return $result;
 }

I need to implement this in either php or javascript.

Gaurav Arora
  • 63
  • 1
  • 10

2 Answers2

2

You cannot do this with PHP or any other server side technology.

You might be able to do this with a browser plugin or a flash app.

Ask yourself why you want to do this?

Toby Allen
  • 10,997
  • 11
  • 73
  • 124
1

This is possible with the storage apis provided by javascript nowadays.

http://www.html5rocks.com/en/tutorials/file/dndfiles/

However if you need raw read/write access, I suggest you read up on the chrome platform apis.

vInsert
  • 94
  • 3