0

Hi,

I'm trying to develop a PHP script which will calculate the internet connection speed of the users. In order to achieve this, the script will perform 5 basic tasks :

1) Fetch the time and store the value in a variable (say: $start_time)
2) Transfer a chunk of data (maybe a image or some other data file) to the user's PC which will be of approx. 250KB.
3) When the download finishes, fetch the time and store the value in a variable (say: $end_time)
4) Calculate the difference between the two times. ($end_time - $start_time) and store the output in another variable (say: $time_taken)
5) Do the appropriate maths to get the speed in KB/s. [I'm not elaborating this since its not necessary right now).


Now, I'm having trouble with step 2 only. In other words, I don't know how to make my script do this step. I want a chunk of data to be transferred to the user's PC. Can anyone tell me which PHP function will be used here?

Regards.

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by richieking
0

You can use

$start_time = date():
$file_valid = move_uploaded_file($tmpname,PATH.$file_name);
if($file_valid){
    $end_time = date();
}
$time_taken = $end_time-$start_time;
//calculate the Data Transfer Rate into Kb/s or etc.

I hope this will help you!

0

@akvlko : Won't this operation take place within the server itself without any actual transfer of file happening between the server and the User's PC because I think this function is used for moving a file within the same server... or am I wrong?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.