Problem :
I am having difficulty with reliably sending numerous files via HTTP Post from one web server to another.
I’ve noticed the success of files being transferred over is dependent on the size and amount of files I choose to send.
What I constitute as a successful transfer is if all files sent from the source server appear in the directory of the receiving server.
//sender script
$ch = curl_init();
$data = array(
'file1' => '@/var/www/html/uploadtest/largerfile.zip',
'file2' => '@/var/www/html/uploadtest/largerfile.zip',
'file3' => '@/var/www/html/uploadtest/smallerfile.zip'
);
curl_setopt($ch, CURLOPT_URL, 'http://domain.com/test/reciever.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$res = curl_exec($ch);
if(curl_exec($ch)){
print "Error: " . curl_error($ch);
}
echo $res;
//recieving script
print_r($_FILES); //outputs as blank array on failed transfer
move_uploaded_file( $_FILES["file1"]["tmp_name"], "file1.zip" );
move_uploaded_file( $_FILES["file1"]["tmp_name"], "file2.zip" );
move_uploaded_file( $_FILES["file1"]["tmp_name"], "file3.zip" );
With the current files being sent across none of them arrive at their destination. If I remove one largerfile.zip then the file transfer is successful.
I am looking for error responses by printing $res but I don’t see any despite a failed transfer. *curl_errno* also does not detect anything.
Background :
I’ve been recommended to use FTP previously but the Web API I’ll be using only accepts POST. It’s also likely that the files I need to transfer are around 50mbs.
I’ve also tried changing the following php.ini settings to :
- post_max_size : 100M
- upload_max_size : 60M
You wrote:
I assume you refer to the filesize on your harddisk per each file.
There is a third setting related to file-uploads:
memory_limit. That is because those files will be loaded into memory before saved to disk on the server.You want to transfer three files at once. Every file is about 50 mb. Let’s just sum it up:
That means:
upload_max_filesize(!!) of 60 mb is too low, in case it counts for all three files at once (I can’t remember from top of my head if that is the case or not).post_max_sizeof 100 mb is definitely too low, you will need a higher value here, at least150mand add a bit more on top. See the manual entry for more info.memory_limitis unknown but it’s highly like that it is too low, too.For testing set
memory_limitto0(unlimited) and play around withupload_max_filesizeandpost_max_sizeto match your needs.I hope this helps you to solve your issue.