PHP FTP - Directory name included in ftpnlist

Hi Chaps,

I’m using ftp_nlist to list all files in an ftp directory, but when I view the array, the entire path is displayed, rather than the filename, eg:


rather than:




// FTP Credentials
$ftpServer = "";
$ftpUser = "ServerUser";
$ftpPass = "ServerPassword";


// Connect to FTP Server
$conn = @ftp_connect($ftpServer)
or die("Couldn't connect to FTP server");

// Login to FTP Site
$login = @ftp_login($conn, $ftpUser, $ftpPass)
or die("Login credentials were rejected");

// Set FTP Passive Mode = True
ftp_pasv ($conn, true);

$ftpPath = ftp_pwd($conn);

// Show Active FTP Directory
echo "You are in the directory: $ftpPath";

// List Directory Files
<br><br>Files for directory: <?php echo $ftpPath; ?><br><br>
<img src="images/upload.png" />Upload file<br><br><?php

$a = ftp_nlist($conn, $ftpPath);
foreach($a as $value){
if(strpos($value,'.') > 0){?>
<img src="images/file.png" /><?php echo $value;?> <a href="<?php echo $value ;?>"><img src="images/download.png" border="0"/></a><img src="images/delete.png" /><br/>
<?php }else{ ?>
<img src="images/folder.png" /><?php echo $value;?> <br/>
<?php ;

Any ideas?

see basename()

Top Man, many thanks!