Hey--
I thought I'd make a function because it would be much easier to work with, because many of the code repeats itself...
So I made one but I get these errors:
Warning: ftp_rawlist() expects parameter 1 to be resource, string given in C:\xampp\htdocs\ftp.php on line 54
Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\ftp.php on line 33
Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\ftp.php on line 56
I have included the better half of the code, I don't think that the rest is needed, but please let me know if it is!
function spider($conn, $dir) {
$buff = ftp_rawlist($conn, $dir);
$items = itemize_dir($buff);
foreach($items as $line=>$item)
{
$file = $ftp . $dir . $item['name'];
$fh = fopen('ftp.txt', 'a') or die("can't open file");
fwrite($fh, $file . "\n");
fclose($fh);
echo $file;
echo "<BR>";
If($item['type'] == 0) {
$work = spider($ftp_host, $dir . $item['name']);
} } }
$work = spider($ftp_host, '/' );
Thanks! 😉