sunilvadranapu Posted November 12, 2009 Share Posted November 12, 2009 Hi, i'm trying to upload files with FTP_PUT in my PHP script. but when i run the scirpt i'm getting the warnging - PHP Warning: ftp_put(): Can't open data connection. in /tmp/sun/test.php on line 70 I'm not sure why my code is failing. Below is the PHP script using to FTP files. <?php $ftpServer = $argv[1]; $localpath = $argv[2]; $rempath = "/home/sun/data"; $connId = ftp_connect($ftpServer); $loginRes = ftp_login($connId, "root", "root"); if((!$connId) || (!$loginRes)){ die("Ftp failed"); } ftp_pasv($connId, true); ftp_site($connId, 'UMASK 013'); if ($handle = opendir($localpath)) { while (($filename = readdir($handle)) !== false) { if (is_file("$localpath/$filename")) { if(ftp_put($connId, "$rempath/$filename", "$localpath/$filename", FTP_ASCII)){ $rfsize = ftp_size($connId, "$rempath/$filename"); if(function_exists('ftp_chmod')){ ftp_chmod($connId, 0764, "$rempath/$filename"); } } } } closedir($handle); ftp_close($connId); ?> could anyone help me by figuring out the error in above code. Thanks in advance. Quote Link to comment Share on other sites More sharing options...
ram4nd Posted November 12, 2009 Share Posted November 12, 2009 maybe you don't have writing permissions for that folder Quote Link to comment Share on other sites More sharing options...
sunilvadranapu Posted November 13, 2009 Author Share Posted November 13, 2009 I have permissions to write on target directory. moreover it is working fine when number of files to be copied in source directory is less than 1000. but when backlog count increased then FTP connection(ftp_put) was failing. is there any mechanism to handle it in more better way. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.