stevesimo Posted November 7, 2008 Share Posted November 7, 2008 Hi, I have a textfile which I need to upload to a remote server but am getting no joy. Can anyone spot what might be causing the problem from my code. I have substituted ip address and username and password: $localfile = 'test.txt'; $ch = curl_init(); $fp = fopen ($localfile, "r") or die('Cannot open textfile'); curl_setopt($ch, CURLOPT_URL,"sftp://123.123.123.123:10022/username/test.txt"); curl_setopt($ch, CURLOPT_USERPWD, "username:password"); curl_setopt($ch, CURLOPT_UPLOAD, 1); curl_setopt($ch, CURLOPT_INFILE, $fp); if(curl_exec($ch)){ echo 'File was successfully transferred using SFTP'; }else{ echo 'File was unable to be transferred using SFTP'; } curl_close ($ch); any advice would be greatly appreciated. Steve 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.