|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now! |
|
#1
|
|||
|
|||
|
FTP isfile and isdir ?
I'm working on a little ftp browsing script...
I need to know if there is a way to check if something in an ftp folder is a file or a directory. PHP Code:
The only problem is, if you click on a file, it tries to load up a new directory. So I need to check to see if it's a file or a directory. any help? |
|
#2
|
||||
|
||||
|
maybe you could parse the return values from ftp_rawlist(). there are some good user comments on that page.
the annotated manual kicks much booty. |
|
#3
|
|||
|
|||
|
I figured that it may come down to that, I was kind of hoping there would be an isfile and isdir though
![]() |
|
#4
|
|||
|
|||
|
Hi,
Probably best to use ftp_rawlist() like what has been mentioned already as nlist() can not handel spaces in the directory name. As far as if there is a comand for seeing if the content in a folder is a file or a directory then there is such a command.. follow the links below. They are is_dir() and is_file() hope this helps :-) http://nz2.php.net/manual/en/function.is-dir.php http://nz2.php.net/manual/en/function.is-file.php if your looking for a nice piece of software to prase ftp_rawlist() try this. function dirList ($connection, $dir_path){ // This function will sort dir struture into files and folders $list = ftp_rawlist($connection, $dir_path); // Returns a list of files and folders //_________sort into two arrays ...files/folders ________ global $folders; global $files; for($i=0;$i<sizeof($list);$i++){ list($permissions,$next)=split(" ",$list[$i],2); list($num,$next)=split(" ",cutspaces($next),2); list($owner,$next)=split(" ",cutspaces($next),2); list($group,$next)=split(" ",cutspaces($next),2); list($size,$next)=split(" ",cutspaces($next),2); list($month,$next)=split(" ",cutspaces($next),2); list($day,$next)=split(" ",cutspaces($next),2); list($year_time,$filename)=split(" ",cutspaces($next),2); if($filename!="." && $filename!=".."){ if(substr($permissions,0,1)=="d"){ $folders[]=$filename; } else { $files[]=$filename; } } } sort($folders); sort($files); } |
|
#5
|
|||
|
|||
|
I know there are is_file and is_dir functions. but that won't work if I'm trying to see if an FTP folder has a file or dir.
I figured it out though.. quite interesting too. PHP Code:
|
|
#6
|
|||
|
|||
|
Yes your right :-)
Nice piece of coding to .. well done just watch the directory names with using ftp_nlist. I got caught out with this and it took me a while to figure out ![]() |
![]() |
| Viewing: Dev Shed Forums > System Administration > FTP Help > FTP isfile and isdir ? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|