How to calculate the internet upload speed using php?When i searched in google i get sites that offer free tests,but i need the code to calculate it.Kindly help me.Thanks in advance.
Internet upload speed calculation using php
I'm not sure of any way to do this that doesn't use some kind of 3rd party programming language. I guess if you could get something to check the file size of the temporary file that is uploaded you could kind of calculate it, but again I've never seen anyone do this with straight PHP.
I have a friend that did one in straight PHP but for some reason I can't find the site it's hosted at. What he did was used header() commands to send a file of a certain size, timed it, and did the math to work out the download speed, then uploaded that file back from their computer to his server for the upspeed.
This is unlikely, horizon. You can test DOWNLOAD speeds this way -- it's fairly easy -- but UPLOAD speeds are practically impossible to measure.
Browsers are forbidden from providing OS informaton about the user's computer. So you don't know what files the customer has, ergo you can't upload a test file.
The browser user must use a file submit form to allow access to a single file for upload. So unless you explicitly ask the user to download a file of a specific size (which would require a download/save dialog), then ask the user to find and upload the same file, you won't be able to test upload speed. Which is not, by the way, the same as download speed, not by a long shot.
For my part, I'd rather just press the upload button and hope for the best than to download and then to upload a test file to see if your PHP program can then calculate the speed with which my file will be uploaded.
Since you won't know the SIZE of the upload file UNTIL IT HAS BEEN UPLOADED (another browser limitation) you will not be able to estimate how long the upload will take. You could only estimate the upload rate, not the ultimate elapsed length of time required.
It is difficult to calculate the upload speed without uploading a file.But If we have a form for choosing a file to upload,file size may vary.
Is there any way to create a default file through the script in client side and upload it to the server?
I created an 1MB file in php and wrote the contents of this file in a test file in the server.When i calculated the time taken for writing the contents, it shows the same time.This is because, as php is server side scripting all the operations occur in the server, and the file is not uploaded from the client.
But in some websites they calculate both upload and download speed.
phppros wrote:Is there any way to create a default file through the script in client side and upload it to the server?.
The point I have tried to make is that there is no way to do this with demanding a lot of complicated input from the user. There is no way to do this 'in the background'.
phppros wrote:I created an 1MB file in php and wrote the contents of this file in a test file in the server.When i calculated the time taken for writing the contents, it shows the same time.This is because, as php is server side scripting all the operations occur in the server, and the file is not uploaded from the client.
But in some websites they calculate both upload and download speed.
There is no accurate way to do calculate upload speeds, which vary greatly from download speeds. You can however, do a lot of tricky programming based on Javascript to calculate download speeds without the user's permission. This is how those 'modem speed tests' get done. Some websites ask permission to download an add-on or x-control type elment that resides on the user's computer; the browser can access a user-installed element and could use it to measure upload speeds. Again that requires effort on the part of the user to download and install; it is not transparent.