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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:47:51+00:00 2026-05-22T20:47:51+00:00

I am connected to the server via the PHP ftp_ functions. How can I

  • 0

I am connected to the server via the PHP ftp_ functions.

How can I measure the transfer speed?

  • 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-22T20:47:52+00:00Added an answer on May 22, 2026 at 8:47 pm

    This is how I brutalized the phihag’s code to check non-blocking upload speed. You can’t use ftp_size() while non-blocking transfer is ongoing, therefore you need a secondary connection just for that purpose. I’m displaying current speed, average speed, elapsed time and estimated time left.

    $primary_connection = ftp_connect($server);
    $secondary_connection = ftp_connect($server);
    
    $mode = FTP_BINARY;
    $login = ftp_login($primary_connection, $ftp_user_name, $ftp_user_pass);
    $login2 = ftp_login($secondary_connection, $ftp_user_name, $ftp_user_pass);
    
    if (!$primary_connection || !$login) { die('Connection attempt failed!'); }
    ftp_pasv($primary_connection,TRUE);
    ftp_pasv($secondary_connection,TRUE);
    
    $upload_status=ftp_nb_put($primary_connection, $destination_file, $source_file, $mode);
    
    define('ALPHA', 0.2); // Weight factor of new calculations, between 0 and 1
    $filesize=filesize($source_file);
    $transferred = 0;
    $rate = 0;
    $time = microtime(true);
    
    $start_time=$time;
    
    while($upload_status == FTP_MOREDATA){
    
        $upload_status = ftp_nb_continue($primary_connection);
    
        $sizeNow=ftp_size($secondary_connection,$destination_file);
        $sizeNowkB=$sizeNow/1024;
        $timeNow = microtime(true);
    
        $currentRate = ($sizeNow - $transferred) / ($timeNow - $time);
        $currentkBRate = $currentRate / 1024;
    
        $rate = ALPHA * $currentRate + (1 - ALPHA) * $rate;
        $time = $timeNow;
        $transferred = $sizeNow;
    
        printf("Uploading file: %s",$source_file);
        echo "<br>\n";
    
        printf( "To be transferred: %0.2f kB", $filesize/1024);
        echo "<br>\n";
    
        printf( "Transferred: %0.2f kB", $sizeNowkB);
        echo "<br>\n";
    
        printf( "Current speed: %0.2f kB/s", $currentkBRate);
        echo "<br>\n";
    
        printf( "Average speed: %0.2f kB/s", $rate/1024);
        echo "<br>\n";
    
        $elapsed_time=$timeNow - $start_time;
        printf( "Elapsed time: %0.2f s", $elapsed_time);
        echo "<br>\n";
    
        if($rate!=0){
            $eta=$filesize/$rate - $elapsed_time;
        }else{
            $eta=0.0;
        }
        if($eta<=0){
            $eta=0.0;
        };
        printf( "Estimated time left: %0.2f s", $eta);
        echo "<br>\n";
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Server 1 is connected to Server 2 via SSH. We know this: I can
I need to use PHP to connect to a URL via a proxy server.
I have connected to a server via SFTP using FileZilla and accepted adding the
I can connect to my SQL Server database via sqlcmd from a DOS command
hy guys, i really need your help. i've succesfully connected to ftp server via
I am trying to connect to an IRC server via PHP on a command
I've successfully tested a connection via PHP's odbc_connect() to a SQL Server 2005 Express
I'm trying to connect to my localhost MySQL server via php in the terminal.
I attempting to connect to a server via PHP fsockopen to initially get a
I'm trying to connect to my LDAP server via PHP, but I get the

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.