Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7659123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:17:27+00:00 2026-05-31T13:17:27+00:00

<?php $localfile = ‘test1.txt’; $fp = fopen ($localfile, r) or die(‘Cannot open textfile’); $connection

  • 0
<?php 
  $localfile = 'test1.txt';
  $fp = fopen ($localfile, "r") or die('Cannot open textfile');
  $connection = ssh2_connect('sftp_server_path/folder',22);
  ssh2_auth_password($connection, 'username', 'password');

  $sftp = ssh2_sftp($connection) or die ("Cannot connect to server");


  $ch = curl_init(); 
  curl_setopt($ch,      CURLOPT_URL,"sftp_server_path/folder/test1.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';
  }

?>

I have the above code to connect and transfer to sftp server and i run this code i am getting message “File was successfully transferred using SFTP”. but when i see the folder structure in sftp server i can’t see my transfer file on sftp server. what exactly i have to do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T13:17:27+00:00Added an answer on May 31, 2026 at 1:17 pm

    Try the following:

    $sftp = ssh2_connect('shell.example.com', 22);
    ssh2_auth_password($sftp, 'username', 'password');
    
    ssh2_scp_send($sftp, '/local/filename', '/remote/filename', 0644);
    

    https://www.php.net/manual/en/function.ssh2-scp-send.php

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wonder if someone can help me; In PHP you can use fopen(Path) to
I have the following code: if (include_once(dirname(__FILE__).'/file.php') || include_once(dirname(__FILE__).'/local/file.php') ) { This causes an
I'm using the PECL intl module to localize dates and numbers in a PHP
php Code: foreach ($html->find('table') as $noscript) {echo $data; echo $data; echo $noscript->innertext . <br>;
PHP is automatically escaping my quotes before writing to a file using fwrite. I
PHP has a great function called htmlspecialcharacters() where you pass it a string and
PHP's explode function returns an array of strings split on some provided substring. It
PHP, as we all know is very loosely typed. The language does not require
PHP stores its session information on the file system of the host of the
PHP treats all arrays as associative, so there aren't any built in functions. Can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.