|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
listing ftp directories
i am developing a site where users are able to browse files and directories stored on an ftp server. it looks a lot like windows explorer, where you have directory listing in a frame to the left.
my problem is that when there are a lot of files, the directory tree takes a LONG time to display (sometimes over 1 minute). the time consuming part is when i retrieve the file list from the ftp server (the parsing part is relatively fast). if i could just retrieve a list of the directories, and not the files, it would help me a lot i think. does anyone know if this can be done using php's built in ftp functions? or do you have any other suggestions? |
|
#2
|
||||
|
||||
|
PHP Code:
Check out ftp_rawlist for more information, also you might want to print out $val in the forloop that way you can see what info it really gives. Also I know you can get the directory name in the preg_matches also and thus cut out the line $dirname = substr(strrchr($val, " "), 1); and replace it with $matches[2] I just don't know what the regex is somone else know it? This is an example of how the data is written out.Code:
drwxrwxrwx 3 10300 0 512 Mar 18 2002 cronscripts -rw-r--r-- 1 10300 0 0 May 8 2002 index.html drwxr-xr-x 7 65534 65534 2048 Dec 19 20:17 phpMyAdmin drwxr-xr-x 3 10300 0 2048 Apr 2 2002 phpPgAdmin drwxrwxrwx 13 10300 0 512 May 27 2002 weblogs everything but index.html is a directory so as you see it starts all directories with d and all that is needed is to get the last word after the last space.
__________________
Miscellaneous Software Viper_SB Developershed E-Support Anyone else play chess? Challenge me |
|
#3
|
|||
|
|||
|
i think you misunderstood me. i know perfectly well how the listing is done (even the recursive part). my problem is that it takes such a long time to get the list from the ftp server, and i was hoping you guys could give me som help optimizing it.
what i want to do is to list ALL directories and subdirectories belonging to the active user in a nice explorer-like directory tree. this i know how to do, but it is very time consuming. |
|
#4
|
||||
|
||||
|
ah ic your point sorry
you want to see them all at once? I tried this once and found that it takes way to long to go though all directories, what about just showing there home dir with directories and then they click it and browse each dir like the old NC or MC? |
|
#5
|
|||
|
|||
|
yeah, that was version 1
but then my employer thought it would be nice to be able to see the whole directory tree in a separate frame.if there's just a few files and directories it takes only 2 or 3 seconds to load the frame, but in some cases it takes well over one minute, and sometimes the script even times out. (raising the time out limit is not an option here, no one should wait more than 10 seconds for a page to be displayed) |
|
#6
|
||||
|
||||
|
Yep I agree that is to long
, I'm out of ideas besides telling your employer that if they want that feature then they'll have to sacirfice speed, maybe give the user the option to have either version displayed and see how many go for the speed instead of the features. Another thing if they user doesn't change the directory structure but only changes files keep the dir tree in an array or something then that is just pasted on each page and would only be slow the first time they accessed it or if they made changes to the structure. |
![]() |
| Viewing: Dev Shed Forums > System Administration > FTP Help > listing ftp directories |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|