Page 1 of 1

scanning a client-side directory

Posted: Wed Feb 04, 2009 8:10 am
by PZAnders
Hi,

Is it possible for the remote client to run scandir() from my web server to scan his/her directories? At the moment scandir() is returning a list of directories on the server side. I need the function to scan the directory of who ever is accessing the web server. i.e. on the web server there might be these directories:
D:\Folder1a
D:\Folder1b
D:\Folder1c

On the Client accessing the site, he / she might have these directories:
D:\Folder2a
D:\Folder2b
D:\Folder2c

When the page is accessed, it is obviously shows:
Folder1a, Folder1b, Folder1c
I need it to show:
Folder2a, Folder2b, Folder2c

here is my code:
//collects the drive from the previous page's post, this works as it echo's out
$dir = $_POST['drive'];

//check that the directory exists -- my working function that just confirms it is a valid drive or ends
check_dir($dir);

$list = array_diff( scandir( $dir ), Array( ".", "..", "Thumbs.db" ) );

foreach($list as $folder)
{
if(is_dir($folder))
{
echo "$folder<br>";
}
}

Any help advice would be much appreciated!
Many thanks

Re: scanning a client-side directory

Posted: Wed Feb 04, 2009 8:18 am
by VladSun
PZAnders wrote:Is it possible for the remote client to run scandir() from my web server to scan his/her directories?
No, it's not possible.

Re: scanning a client-side directory

Posted: Wed Feb 04, 2009 8:42 am
by Skoalbasher
My answer from another thread is much better suited here.

Have you tried Javascript?

Re: scanning a client-side directory

Posted: Wed Feb 04, 2009 8:51 am
by PZAnders
Thanks for the swift response! Albeit abrupt and not the answer I was hoping for!! :roll:

Haven't had much experience with Javascript, think I should start learning it!
Cheers guys

Re: scanning a client-side directory

Posted: Wed Feb 04, 2009 8:57 am
by VladSun
JavaScript has no permissions to work with local file system except cookies. You need a plugin (FF, etc.) or ActiveX control (IE).

Re: scanning a client-side directory

Posted: Wed Feb 04, 2009 9:05 am
by Skoalbasher
VladSun wrote:JavaScript has no permissions to work with local file system except cookies. You need a plugin (FF, etc.) or ActiveX control (IE).
Hmm, I didn't know that. I just figured it could somehow. I mainly use it for AJAX functionality.

Re: scanning a client-side directory

Posted: Wed Feb 04, 2009 10:13 am
by John Cartwright
Could you imagine the security vulnerabilities, not the mention breach of privacy, if any website could read the contents of your computer!?

Re: scanning a client-side directory

Posted: Wed Feb 04, 2009 10:28 am
by Skoalbasher
Jcart wrote:Could you imagine the security vulnerabilities, not the mention breach of privacy, if any website could read the contents of your computer!?
Yeah, I never really even considered that. I guess I was thinking about Java, not javascript