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 Link to comment https://forums.phpfreaks.com/topic/131767-upload-textfile-using-curl-sftp/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.