Page 1 of 1

FTP using php

Posted: Wed Oct 31, 2007 4:55 am
by php3ch0
I am having a problem with uploading a file via ftp to google base.

I keep getting the error:
Warning: ftp_login() expects parameter 1 to be resource, boolean given in /home/l/a/laptopcentre/public_html/fulladmin/froogle.php on line 329

Warning: ftp_pasv() expects parameter 1 to be resource, boolean given in /home/l/a/laptopcentre/public_html/fulladmin/froogle.php on line 330
code is as follows

Code: Select all

// ...some code
$conn_id = ftp_connect($ftp_server); 

ftp_pasv($conn_id, true);

// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_password);
// some more code ...
where $ftp_server = uploads.google.com
and username and password are correct as I can connect using my ftp program.

Please help

Posted: Wed Oct 31, 2007 6:09 am
by xitura
ftp_pasv returns a boolean, that's why you get that error message. You need to connect first and then turn passive mode on. Just as it says in the example for ftp_pasv on php.net

Posted: Wed Oct 31, 2007 7:45 am
by php3ch0
ok i have changed the code so i log in first then change to pasv mode

Code: Select all

$conn_id = ftp_connect($ftp_server); 

$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_password); 
ftp_pasv($conn_id, true);
still getting this message
Warning: ftp_login() expects parameter 1 to be resource, boolean given in /home/l/a/laptopcentre/public_html/fulladmin/froogle.php on line 329

Warning: ftp_pasv() expects parameter 1 to be resource, boolean given in /home/l/a/laptopcentre/public_html/fulladmin/froogle.php on line 330

Posted: Wed Oct 31, 2007 10:33 am
by xitura
ftp_connect returns FALSE on error, please add or die("Couldn't connect to $ftp_server"); to the end of the first line to see if the connection is failing.

Posted: Wed Oct 31, 2007 10:47 am
by php3ch0
yes getting error could not connect to uploads.google.com

Posted: Wed Oct 31, 2007 10:53 am
by xitura
Try changing uploads.google.com to ftp.uploads.google.com