Link to home
Start Free TrialLog in
Avatar of bernardbrink
bernardbrinkFlag for Netherlands

asked on

Access multiple ftp server to upload one file and quit

Hi,
I'm trying to connect to multiple ftp servers, login, put a file, and close the connection.
I'm 100 % sure the password is correct, because a single connection works fine. HTTP connection also.

I'm only getting a resource_id.
I can't find the problem, you guys have any idea ?

Thanks in advantage
<?php
$db = mysql_connect("xxx", "root","xxx")or die("!connect");
mysql_select_db("inv") or die("!db");
$sql = "SELECT address FROM `custom_host_group_members` WHERE group_alias='UPS' ORDER BY display_name";
$array = mysql_query($sql) or die(mysql_error());
while ($result = mysql_fetch_array($array))
{
	$user = "admin";
	$pass = "geheim.old";	
	
	$ip = $result['address'];
	
	echo $conn = ftp_connect($ip);
	echo $login = ftp_login($conn,$user,$pass);
	echo $write = ftp_put($conn,"config.ini","config.ini",FTP_ASCII);
	ftp_close($conn); 
}


?>

Open in new window

Avatar of Shinesh Premrajan
Shinesh Premrajan
Flag of India image

there could be a user permission error.

update the code with the error message

if (ftp_put($conn,"config.ini","config.ini",FTP_ASCII)) {
 echo "successfully uploaded $file\n";
} else {
 echo "There was a problem while uploading $file\n";
}


Hope this helps
Avatar of bernardbrink

ASKER

hi shinug,

The echo on ftp_connect give a resource_id, which is correct...right?
and the echo on ftp_login / ftp_write give nothing back.
the echo on ftp_close gives '1'
Any ideas?
ASKER CERTIFIED SOLUTION
Avatar of bernardbrink
bernardbrink
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial