Hi,
I have script that should do FTP upload of simple txt file to remote server. When I test this script on my local server it works, but when I upload script to actual server where FTP upload should execute I get following errors:
Warning: ftp_fput() [function.ftp-fput]: php_connect_nonb() failed: Operation now in progress (115)
Warning: ftp_fput() [function.ftp-fput]: Type set to ASCII.
and file is not uploaded, so we do connect and login but no uploading. Odd ting to me is that everything works ok from my local server, upload is successful.
Any Help or idea is appreciated.
$file_name = "sitename.txt";
if(!file_exists($file_name))
{
echo "<h2>File not found</h2>";
}
else
{
echo "<h2>File is found</h2>";
}
$fp = fopen($file_name, "r");
if(!$fp)
{
echo "<h2>Cant Open File for reading</h2>";
}
//prepare FTP
$ftp_file_name = "sitename.txt";
$ftp_server = "server.com";
$ftp_user_name = "username";
$ftp_user_pass = "password";
// set up basic connection
$conn_id = ftp_connect($ftp_server, 21) or die("BDX CONNECTION FAILED!");
// login with username and password
if(!$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass))
{
die("BDX CONNECTION FAILED");
}
// turn passive mode on
ftp_pasv($conn_id, true);
// try to upload $file
if (ftp_fput($conn_id, $ftp_file_name, $fp, FTP_ASCII))
{
echo "BDX UPLOAD SUCCESS";
}
else
{
echo "BDX UPLOAD FAILED";
}
// close the connection and the file handler
ftp_close($conn_id);
fclose($fp);