Hey everybody, my names Josh and I’m new to PHP Help Forum. Id just like to say thanks in advance to all the helpers out there.
I’m currently creating an online backup solution for my website, a local one I’ve made to promote my PC Repair / Network Installation/Repair business here in town. It’s going well but I’m having a small hiccup I cant figure out. When the clients log in, and view their Control Panel; I want it to have a list of the files they have uploaded. I have that figured out, but I’m trying to put a particular image to the left of it based on the file extension. I’ve wrote this code, and added a function to it to find the file extension and associate an image with it; but now it stops as soon as it finds the first directory and no longer displays all the contents of the folder.
<?php
function extimg($filename){
$ext = pathinfo($filename, PATHINFO_EXTENSION);
$icon = 'unknown.gif';
if ($ext=='php'){$icon = 'application_dreamweaver.gif';}
$eimg = '<img src="'.$icon.'">';
}
$ftp_server = "ftp.syncupsolutions.net";
$ftp_user = "******";
$ftp_pass = "**********";
// set up a connection or die
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
echo "Connected as $ftp_user@$ftp_server\
";
} else {
echo "Couldn't connect as $ftp_user\
";
}
$result = ftp_nlist($conn_id,"/");
if(is_array($result))
{
foreach($result as $line)
$extention=extimg($line);
{
echo $extention . "$line\
" . "</br>";
}
}
else
{
echo "No data returned.";
}
// close the connection
ftp_close($conn_id);
?>