I need to send files to my ftp server(vsftpd) via php. When i call function print_r(error_get_last());
after ftp_put()
i can see:
Warning: ftp_put(): php_connect_nonb() failed: No error (0)
Warning: ftp_put(): Switching to Binary mode.
Fatal error: Maximum execution time of 60 seconds exceeded
And files not sending.
Here is my vsftpd config. I also have opened 20,21,990,4000-5000 ports:
listen=NO
listen_ipv6=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
connect_from_port_20=YES
chroot_local_user=YES
secure_chroot_dir=/var/run/vsftpd/empty
pam_service_name=vsftpd
rsa_cert_file=/etc/ssl/private/vsftpd.pem
rsa_private_key_file=/etc/ssl/private/vsftpd.pem
ssl_enable=NO
allow_writeable_chroot=YES
pasv_min_port=40000
pasv_max_port=50000
userlist_enable=YES
userlist_file=/etc/vsftpd.userlist
userlist_deny=NO
My php upload script:
public function upload($file, $path, $fileName){
global $ftp_config;
$conn_id = ftp_connect($ftp_config['host']);
if($conn_id)
{
$login_result = ftp_login($conn_id, $ftp_config['username'], $ftp_config['password']);
ftp_pasv($conn_id, true);
print_r('/'.$path.''.$fileName);
$upload = ftp_put($conn_id, '/'.$path.''.$fileName, $file, FTP_IMAGE);
print_r(error_get_last());
return $upload;
}
return false;
}
In other hand its easy to send the same files with FileZilla.
Have any ideas? Thanks.
Solved problem.
My FTP client was behind NAT, so i just add pasv_address=[your_ip]
in my vsftpd.conf