Advertisement
btcraig

Untitled

Feb 25th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. <?php
  2. ////FOR SFTP
  3. ini_set('error_reporting', E_ALL);
  4.  
  5. $strServer = "ftp.digitalriver.com.wip.digitalrivercontent.net";
  6. $strServerPort = "2222";
  7. $strServerUsername = "ms_api";
  8. $strServerPassword = "tenroh";
  9. $csv_filename = "test.csv";
  10.  
  11. //connect to server
  12.  
  13. $resConnection = ssh2_connect("$strServer","$strServerPort");
  14. if ($resConnection) die('Connection failed');
  15.  
  16. if(ssh2_auth_password($resConnection, $strServerUsername, $strServerPassword)){
  17.  
  18.  
  19. //Initialize SFTP subsystem
  20.  
  21. echo "connected";
  22. $resSFTP = ssh2_sftp($resConnection);
  23. var_dump($resSFTP);
  24. $resFile = fopen("ssh2.sftp://".$resSFTP."/Magento/".$csv_filename, 'w');
  25. $srcFile = fopen("/chroot/home/bluehorn/magentodev.bluehornet.com/html/".$csv_filename, 'r');
  26. $writtenBytes = stream_copy_to_stream($srcFile, $resFile);
  27. fclose($resFile);
  28. fclose($srcFile);
  29. echo "Uploaded successfully";
  30.  
  31. }else{
  32. echo "Unable to authenticate on server";
  33. }
  34.  
  35.  
  36. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement