Upload is slow via curl and fast via Browser
I'm using curl to upload backups of my files to a server as a post
request. The request is up to 10X slower than sending the same file via
the browser, how is this possible? The Files are between 500MB and 4GB,
one file per request. Here is the request:
$file = realpath("500MB.rar");
$postfields[] = "@".$file;
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
$return = curl_exec($ch);
I'm using WAMP on Windows Server 2008 (PHP 5.3.13), I've also tried it
with XAMPP and with IIS, but it is always slow. It is not limited by the
network connection, curl is able to upload with 100% of the network
connection, but only if the server I'm trying to upload to is significant
faster. So the speed is limited by the remote server but it never reaches
the possible speed of the remote server. Like curl would be set up to only
use 10% of the possible speed. This is really strange IMO. Is it because
it always reads from the HDD? Is there a way to buffer the file? Is there
any other solution?
I can't use FTP since the remote server is a regular Filehosting service.
Thanks for any help or tips in advance.
No comments:
Post a Comment