Read dir

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
Jose Arce
Forum Commoner
Posts: 37
Joined: Wed May 01, 2002 5:05 pm

Read dir

Post by Jose Arce »

hi, i'm so new to php and i like to know if i can read dirs in another server...i heard it was possible..but dunno how, please help me here
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Re: Read dir

Post by phice »

Jose Arce wrote:hi, i'm so new to php and i like to know if i can read dirs in another server...i heard it was possible..but dunno how, please help me here
Not not quite sure if this is even possible, due to the security threats other servers have. Although, I'm not exactly sure if this is right, or not.
User avatar
fatal
Forum Contributor
Posts: 118
Joined: Sat Apr 20, 2002 10:47 am
Location: East Coast

Post by fatal »

yes ive seen examples that can open remote files. Use fopen() or maybe the opendir() function to open the file in question, then you can go from there.
User avatar
fatal
Forum Contributor
Posts: 118
Joined: Sat Apr 20, 2002 10:47 am
Location: East Coast

Post by fatal »

Also look at this topic from the forums, http://www.devnetwork.net/forums/viewtopic.php?t=149 more or less what you want (i think).
dusty
Forum Contributor
Posts: 122
Joined: Sun Apr 28, 2002 9:52 pm
Location: Portsmouth, VA

Post by dusty »

using fopen and opendir are 2 completely different things. listing directory contents isn't possible across 2 different servers.
Jose Arce
Forum Commoner
Posts: 37
Joined: Wed May 01, 2002 5:05 pm

Post by Jose Arce »

dusty wrote:using fopen and opendir are 2 completely different things. listing directory contents isn't possible across 2 different servers.

Ok...thx :(
User avatar
sam
Forum Contributor
Posts: 217
Joined: Thu Apr 18, 2002 11:11 pm
Location: Northern California
Contact:

Post by sam »

Well you could do a directory listing on the remote server feed the output to XML or something and then read it from the other server... Might be a bit more complex than you wanted :mrgreen:

Cheers Sam
Jose Arce
Forum Commoner
Posts: 37
Joined: Wed May 01, 2002 5:05 pm

Post by Jose Arce »

bit more coplex?
well, kinda another level for me jeje....but i'm willing to learn, don't you have a tutorial or somenthig? maybe a page...
User avatar
sam
Forum Contributor
Posts: 217
Joined: Thu Apr 18, 2002 11:11 pm
Location: Northern California
Contact:

Post by sam »

Well on one server you ahve to use the opendir and readdir functions to get the directory contents... you have to then out put them with some kind of formating so that you can read them again. IE XML and then from the other server you have to use an fopen to read the page and then display the information. You have to have php enabled on both servers and have to have access to both as well.

Cheers Sam
Jose Arce
Forum Commoner
Posts: 37
Joined: Wed May 01, 2002 5:05 pm

Post by Jose Arce »

but if i have no access for one of them...it will not be possible?
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Post by phice »

fatal wrote:yes ive seen examples that can open remote files. Use fopen() or maybe the opendir() function to open the file in question, then you can go from there.
fopen(); will do the exact same thing, as if you went to the site directly, in Internet Explorer, and did a Right Click > View Source... Even if you did fopen();'d a remote file, on another server, you'd only get the HTML output, and no PHP code, much like the View Source trick, also.

opendir(); is strictly allowed to your server, and your server only. It will read the files on the directory that you specify, and generate a list of the file names.
MacDaddy
Forum Newbie
Posts: 12
Joined: Sun May 05, 2002 9:36 pm
Location: Atlanta, GA

Post by MacDaddy »

true...the opendir(); function can be used to view files on a server that you aren't supposed to be viewing

But, that's only on the server that the file was uploaded on
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Post by phice »

MacDaddy wrote:true...the opendir(); function can be used to view files on a server that you aren't supposed to be viewing

But, that's only on the server that the file was uploaded on
exactly ;)
Post Reply