scanning a client-side directory

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
PZAnders
Forum Newbie
Posts: 4
Joined: Wed Feb 04, 2009 7:40 am

scanning a client-side directory

Post 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
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: scanning a client-side directory

Post 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.
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
Skoalbasher
Forum Contributor
Posts: 147
Joined: Thu Feb 07, 2008 8:09 pm

Re: scanning a client-side directory

Post by Skoalbasher »

My answer from another thread is much better suited here.

Have you tried Javascript?
PZAnders
Forum Newbie
Posts: 4
Joined: Wed Feb 04, 2009 7:40 am

Re: scanning a client-side directory

Post 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
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: scanning a client-side directory

Post by VladSun »

JavaScript has no permissions to work with local file system except cookies. You need a plugin (FF, etc.) or ActiveX control (IE).
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
Skoalbasher
Forum Contributor
Posts: 147
Joined: Thu Feb 07, 2008 8:09 pm

Re: scanning a client-side directory

Post 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.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: scanning a client-side directory

Post 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!?
User avatar
Skoalbasher
Forum Contributor
Posts: 147
Joined: Thu Feb 07, 2008 8:09 pm

Re: scanning a client-side directory

Post 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
Post Reply