about ftp functions, and about listing all files...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mickey
Forum Newbie
Posts: 24
Joined: Thu May 01, 2003 11:14 am
Location: Philippines

about ftp functions, and about listing all files...

Post by mickey »

hi,

this problem i haven't sovled for 2 days..

you see, when i place this php code on a different server, it works.

Code: Select all

$ftp_id = ftp_connect("ftp.mobilemo.com");
$ret = ftp_login($ftp_id, "mobilem", "xxxxxx");
//$ret = ftp_login($ftp_id, "mickey", "karen");
//print("$ret<br/>");
//$ret = ftp_chdir($ftp_id, "www/");
//print("$ret<br/>");
$ret = ftp_pwd($ftp_id);
print("$ret<br/>");

$files = ftp_nlist($ftp_id, "digitel/midi");
&#123;
	foreach($files as $file)
	&#123;
		$offset = strrpos($file, "&quote;) + 1;
		$ringTone = substr($file, $offset);
		print("<a href="logo2.php?midi=$ringTone?subA=123456789?rldownload=true">$ringTone</a><br/>");
		//$midi = fopen("midi.mid", "wb+");
		//ftp_fget($ftp_id, $midi, $file, FTP_BINARY);
	&#125;
	
&#125;
but when i place the php file itself on the ftp server itself.. along the foreach, it always returns null, ie error, this function is what causing the error:

$files = ftp_nlist($ftp_id, "digitel/midi");

i don't understand why that won't work once the php file is on the ftp server itself..

my 2nd question, if i can't make that to work, is there a file that lists all the files on a current directory? i couldn't find such function on the php manual. this would be my other way around...

many thanks.
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Post by []InTeR[] »

If the php is on the server self, you can use opendir and readdir or scandir.

Are the php version the same on each server?
And does the server know the host?
It can be that the connect or the login failes...
User avatar
Wayne
Forum Contributor
Posts: 339
Joined: Wed Jun 05, 2002 10:59 am

Post by Wayne »

?
you see, when i place this php code on a different server, it works.
? does this mean you put this code on another server and tried connecting to a that server, or were you connecting from that server to the server currently being used??

probably a question you have already considered but does the user you are logging in as have access to that path and files?
mickey
Forum Newbie
Posts: 24
Joined: Thu May 01, 2003 11:14 am
Location: Philippines

Post by mickey »

hello guys,

thanks for the scandir function, that's what i've been looking for. that function wasn't listed on my php book and i feel akward connect to an ftp server where the php file is already on that server itself.

again, many thanks for the scandir function, :)
Post Reply