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 8253955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:03:24+00:00 2026-06-08T01:03:24+00:00

I am trying to transfer a file from one server to another. I am

  • 0

I am trying to transfer a file from one server to another. I am using php5 with curl

$fp = fopen("/tmp/help.txt", "r");    
$url = "ftp://admin:support@portal-test.uk.xxx.com:21/tmp/help.txt";    
$ch = curl_init();        
curl_setopt($ch, CURLOPT_URL, $url);     
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);     
curl_setopt($ch, CURLOPT_UPLOAD, 1);     
curl_setopt($ch, CURLOPT_INFILE, $fp);     
//curl_setopt($ch, CURLOPT_FTPASCII, 1);     
curl_setopt($ch, CURLOPT_INFILESIZE, filesize(__FILE__));     
$result = curl_exec($ch);         
print_r(curl_getinfo($ch));    
echo "\n\ncURL error number:" .curl_errno($ch);    
echo "\n\ncURL error:" . curl_error($ch);   
curl_close($ch); 

I get an error as below:

Array
(
    [url] => ftp://admin:support@portal-test.uk.xxx.com:21/tmp/help.txt
    [content_type] => 
    [http_code] => 550
    [header_size] => 0
    [request_size] => 0
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 0.033012
    [namelookup_time] => 0.015422
    [connect_time] => 0.015798
    [pretransfer_time] => 0
    [size_upload] => 0
    [size_download] => 0
    [speed_download] => 0
    [speed_upload] => 0
    [download_content_length] => 0
    [upload_content_length] => 0
    [starttransfer_time] => 0
    [redirect_time] => 0
)
cURL error number:9
cURL error:Server denied you to change to the given directory

I want to transfer a file from /tmp/ to another server /tmp/. How would i do this?

  • 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-06-08T01:03:26+00:00Added an answer on June 8, 2026 at 1:03 am

    here is my script which works

    <?php
    error_reporting(E_ALL|E_STRICT);
    ini_set('display_errors', 1);
    date_default_timezone_set('Europe/London');
    set_include_path('.' . PATH_SEPARATOR . '/opt/eposdatatransfer/application/../library' . PATH_SEPARATOR . get_include_path());
    require('Zend/Date.php');
    $use_pasv = true;$ftp_server = "172.16.0.65"; 
    $ftp_user_name = "h3111142";
    $ftp_user_pass = "seismic";
    $ftp_remote_path = "/tmp";
    $ftp_remote_file = array("/files/nas1/epos4/eposbulk/h3111142/seismic/Line_58/0000000500900bc1.000000.00000005.headers","/files/nas1/epos4/eposbulk/h3111142/seismic/Line_58/0000000500900bc1.000000.00000005.headers.ext0","/files/nas1/epos4/eposbulk/h3111142/seismic/Line_58/0000000500900bc1.000000.00000005.history","/files/nas1/epos4/eposbulk/h3111142/seismic/Line_58/0000000500900bc1.000000.00000005.pds","/files/nas1/epos4/eposbulk/h3111142/seismic/Line_58/0000000500900bc1.000000.00000005.pkey","/files/nas1/epos4/eposbulk/h3111142/seismic/Line_58/0000000500900bc1.000000.00000005.traces","/files/nas1/epos4/eposbulk/h3111142/seismic/Line_58/0000000500900bc1.000000.00000005.traces.ext0",) ;
    $ftp_local_file = array(59,59,59,59,59,59,59,) ;
    $emailNotifications = array();
    $GLOBALS['start']="";
    $GLOBALS['current']="";
    date_default_timezone_set ( "Europe/London" );
    
    $conn_id = ftp_connect($ftp_server);
    if (!$conn_id){
        echo "Unable to connect to $ftp_server";
        updateStatus($ftp_local_file[$count], 0);
        exit(1);
    }
    
    $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
    
    if (!$login_result){
        echo "Inavalid login/password for $ftp_user_name on $ftp_server";
        updateStatus($ftp_local_file[$count], 0);
        ftp_close($conn_id);
        exit(2);
    }
    
    ftp_pasv($conn_id, $use_pasv);
    
    if (!ftp_chdir($conn_id, $ftp_remote_path)){
        echo "Invalid remote path $ftp_remote_path";
        ftp_close($conn_id);
        updateStatus($ftp_local_file[$count], 0);
        exit(3);
    }   
    
    $count = 0;
    foreach($ftp_remote_file as $key => $value){
        updateStatus($ftp_local_file[$count], 2);
    
        if(!empty($value)){
            if (ftp_put($conn_id, $value, $value, FTP_BINARY)){
                updateStatus($ftp_local_file[$count], 1);
    
            }else{
                $use_pasv = false;
                ftp_pasv($conn_id, $use_pasv);
    
                if (ftp_put($conn_id, $value, $value, FTP_BINARY)){
                    updateStatus($ftp_local_file[$count], 1);
                }else{
                    updateStatus($ftp_local_file[$count], 0);
                    ftp_close($conn_id);
                    echo "Error while uploading $value";
                    exit(4);
                }
            }
        }
        $count++;
    }
    
    ftp_close($conn_id);
    
    $GLOBALS['current'] = null;
    sendmail($emailNotifications,$ftp_remote_file, $ftp_local_file);
    
    function updateStatus($id, $status){
    
        $con = mysql_connect('hero','eposdata','support');
        if (!$con)
          {
          die('Could not connect: ' . mysql_error());
          }
    
        mysql_select_db('eposdatatransfer', $con);
    
        //$mysqldate = date( 'Y-m-d H:i:s');
        $mysqldate = new Zend_Date();
        if($status == 2){
            if($GLOBALS['current']==$id){
                return;
            }else{
                $GLOBALS["current"] = $id;
            }
            $GLOBALS['start'] = $mysqldate;
            $mysqldate = new Zend_Date($mysqldate, Zend_Date::ISO_8601);
            $start = $mysqldate->toString('Y-MM-dd HH:mm:ss');
            //echo $start;
            mysql_query("UPDATE queue SET status=$status, started='$start' WHERE id=$id");
        }elseif($status == 1){
            $dateDiff = ($mysqldate->getTimestamp() - $GLOBALS['start']->getTimestamp()) ;
    
            $complete = $mysqldate->toString('Y-MM-dd HH:mm:ss');
            mysql_query("UPDATE queue SET status=$status, completed='$complete', duration='$dateDiff' WHERE id=$id");
    
        }else{
            mysql_query("UPDATE queue SET status=$status WHERE id=$id");
        }
    
        mysql_close($con);
    
    }
    
    function sendmail($emailNotifications, $ftp_remote_file, $idArr){   
        $message = "";
    
        $count = 0;
        $data = array();
        foreach($ftp_remote_file as $key => $value){
            if($GLOBALS['current']==$idArr[$count]){
                //return;
            }else{
                $GLOBALS['current'] = $idArr[$count];
                $data = getLineName($idArr[$count]);
                $message =  $message .  $data['data_name'] . "
    ";
            }
    
            $count++; 
        }
    
        $message = $message . "
    Downloaded to Woking" ;
    
        $message = $message . "
    This is an automated message. DO NOT REPLY";
    
        // In case any of our lines are larger than 70 characters, we should use wordwrap()
        $message = wordwrap($message, 70);
    
        //Send
        foreach($emailNotifications as $key => $value){
            mail("$value", 'Transfer Complete Line: ' . $data['line_name'], $message);
        }
    }
    
    function getLineName($id){
        $con = mysql_connect('hero','eposdata','support');
        if (!$con)
          {
          die('Could not connect: ' . mysql_error());
          }
    
        mysql_select_db('eposdatatransfer', $con);
    
        $result = mysql_query("select * from queue WHERE id=$id");
        $row = mysql_fetch_assoc($result); 
    
        return $row;
    
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to transfer a file from one server to a remote server
noob here, I'm trying to transfer a file using rsync from windows to linux.
i am trying to transfer file from user to my server and than upload
i'm trying to download file from http server using WinINet library calls. It works
I'm trying to save a dynamic pdf file generated from a web server using
I am trying to transfer a binary file from the server to the client
I'm trying to make android download a zip file from my web server using
I am trying to transfer data from a jsp file using a json object.
I am trying to transfer from Cherrypy to Bottle & Gevent(server). After I run:
I'm trying to transfer the contents of one list to another, but it's not

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.