The ASP.NET Repeater Control

The ASP.NET Repeater Control Tuesday, January 29, 2008 | Microsoft & .NET The Repeater control is a data-bound control that uses templates to display data. The Repeater control works by looping through the records in your data source and then r...

How to get directory listing with FTP using PHP Print E-mail
User Rating: / 5
PoorBest 

This tutorial will show how you can get directory list of any ftp site by using PHP's in-built functions.
PHP provides number of existing functions which are capable enough to handle almost all kind of FTP operations.

 Below is the code and explanation of the same:

1.	<HTML>
2. <HEAD>
3. <TITLE>
4. Getting a directory listing with FTP
5. </TITLE>
6. </HEAD>
7. <BODY>
8. <CENTER>
9. <H1>Getting a directory listing with FTP</H1>
10. Here's what's in the remote directory:
11. <BR>
12. <?php
13. $connect = ftp_connect("ftp.hostname.com");
14. $result = ftp_login($connect, "username", "password");
15. $a = ftp_nlist($connect, "code22");
16. foreach($a as $value){
17. echo $value, "<BR>";
18. }
19. ?>
20. </CENTER>
21. <BODY>
22. </HTML>


Line 1 - 8        Simple HTML code
Line 9        HTML Heading code for web page
Line 10 - 11    Web page details and line break tag
Line 12        PHP code start tag
Line 13        Assignment of variable $connect with the use of ftp_connect () function
            More details about ftp_connect() and other ftp functions are available at http://www.phpreg.com/index.php?option=com_wrapper&Itemid=42
Line 14        Assigned variable $result using ftp_login() function
Line 15        Used ftp_nlist() function and assigned to variable $a
Line 16        Foreach loop start for each value of directory content.
Line 17        This code will echo all the records in directory list one by one
Line 18        Closed foreach loop
Line 19         Closed PHP code
Line 20 - 22    HTML tags for formatting and body.

 

 
< Prev   Next >