Page 1 of 1

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

Posted: Wed Jun 25, 2003 4:29 am
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.

Posted: Wed Jun 25, 2003 4:36 am
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...

Posted: Wed Jun 25, 2003 7:08 am
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?

Posted: Fri Jun 27, 2003 4:35 am
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, :)