I'm trying to upload a file to a ftp server and I'm having some trouble finding out why the upload is failing.
The following works fine on localhost, uploading my file to the server. Running it on my Azure server it does connect but fails to upload the file.
$file = 'some_file.xml';
$fp = fopen($file, 'r');
$conn_id = ftp_connect('my_ftpserver');
$login_result = ftp_login($conn_id, 'my_user', 'my_password');
if (ftp_fput($conn_id, 'my_filepath/'.$file, $fp, FTP_ASCII)){
echo "Successfully uploaded $file\n";
}
else{
echo "There was a problem while uploading $file\n";
}
ftp_close($conn_id);
fclose($fp);
I've checked that the account have permission to write files and that it does not require sftp. Anything else I should be taking a look at?
Also, I'm new to using ftp with PHP, is there any way I can get the server response codes to try and figure out why the command fails?
Any pointers would be greatly appreciated!