note 52406 deleted from function.ftp-rawlist by crell

From: Date: Thu, 31 Mar 2022 19:28:33 +0000
Subject: note 52406 deleted from function.ftp-rawlist by crell
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-217902@lists.php.net to get a copy of this message
Note Submitter: john at nm-design dot com ---- I'm not a traditional programmer, so I often take a different approach then most programmers. Here's how I get file information from an FTP file list. It's very simple (which I like). Comments are welcome: // make your FTP connection calls here, then ... $contents = ftp_rawlist($ftp_id, "."); echo '<TABLE>'; foreach ($contents as $key => $value) { $info = explode(" ", $value); $clean = array(); foreach ($info as $key => $value) { if (!empty($value)) { $clean[] = $value; } } // end foreach loop 2 if ( ($clean[8] != ".") AND ($clean[8] != "..") AND ($clean[8] != "html") AND ($clean[8] != "logs") AND ($clean[8] != "protected") AND ($clean[8] != "sys") ) { echo '<TR>'; print "<TD WIDTH=\"40%\">$clean[8]</TD>"; // name of file print "<TD WIDTH=\"20%\" ALIGN=\"CENTER\">$clean[5] $clean[6] $clean[7]</TD>"; // date info // prep size $size = $clean[4]; $size = $size / 1000; $size = ceil($size); if ($size <= 0) { $size = 1; } if ($size >= 1000) { $measure = "MB"; $size = $size / 1000; } else { $measure = "K"; } print "<TD WIDTH=\"20%\" ALIGN=\"CENTER\">$size $measure</TD>"; // size echo '<TD WIDTH="20%" ALIGN="CENTER" BGCOLOR="#FFFFE6" CLASS="bodyBold">'; print "<A HREF=\"$PHP_SELF?Submit=DELETE&file=$clean[8]\">"; echo 'DELETE</A></TD>'; // link to delete file echo '</TR>'; } // end if } // end foreach loop 1 echo '</TABLE>';

« previous php.notes (#217902) next »