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.

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!

@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?

You need javascript or Ajax my friend ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.