Click to See Complete Forum and Search --> : List remote directory


enkay
08-11-2008, 04:56 AM
I would like to list a directory that's on another website I own.

I can set any kind of permission and the directory I want to list currently has no index file and displays an apache directory list when opened directly.

I would like to keep it as simple as possible otherwise I'll just use a database.


I read something about using an include file but I'm not sure about how that would work. Any clue?

I think you can also use ftp, but once again I'm not sure how to go about this. Also I read this slows down the process, I don't know if it's true.

http://us.php.net/function.opendir

I would like to use opendir. According to the manual "path supports the ftp:// URL wrapper" and also "path can also be any URL which supports directory listing, however only the file:// URL wrapper supports this in PHP 4". I'm not sure if that's of any help for me. I use PHP 5.something.

What's the difference with fopen? I read that fopen would work on remote directories but opendir wouldn't.

Bottom line is: can anyone shed some light one how I could list files from a remote directory?

As long as I get this task done, any way is fine but the simpler the better. Otherwise, I might aswell just use a database which is what I'm trying to avoid right now.

Thanks.

drhart4000
08-12-2008, 03:29 AM
well, the most simple way is to have a php file located in the directory you want to display on your first server (We'll call this Server 'A').

This file will out put raw xml data for your second server (Yep we'll call this Server 'B').
Server B calls to this file, it reads the xml data and shows it in any form you wish.

It's actually not a very difficult process a lot easier than maintaining a database of all the files in the directory.

May i ask why the files are located on server A, and why you are displaying the directory listing on Server B?

------------
As a side note you can just have everything rendered by the php file on Server A and simply include it in your page on B.

Either way it simply requires 1 on server A and one on B.

-------------------------------------


If you need help with the scripting on this I'll be happy to help you out, let me know.

drhart4000
08-12-2008, 03:38 AM
Here is a good script for use on Server A: http://www.weberdev.com/get_example-4472.html.

Then you need to build another script for Server B that reads this data, a good source for help can be found here: http://www.php.net/manual/en/xml.examples.php

----------------

Hope that's helpful

enkay
08-12-2008, 03:53 AM
Thanks alot for your help. I sent you a private message detailing the situation a little.

I'm not familar at all with xml so at this very moment it's probably best I don't venture too much into it! I'm definately going to keep these links for further studying for my next project.

As I said I currently was able to get what I need done using php. I'm just wondering if any of those methods would be faster than ftp. Rendering everything on server A and just including a file on server B is something I tried doing but didn't have much success. For some reason it kept on trying to find the directory I wanted on server B...

I don't know if it changes anything but the directory it needs to list from site A is inputed by user on site B.