php curl API uploader
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

Hi guys,

I would like a php file that will upload using code and the API of

curl \
-F "" -F "platform=ios"

Can you convert this into php please.

The zip file is hosted on AWS so it may need to be downloaded to the localhost where the php is hosted then run the curl to upload and then remove the zip file after.

More info

do you want to upload the file via form or you have a file path directly?
Subhash Dasyam 14 days ago
no the file is already uploaded to a URL on AWS.
davesargent 14 days ago
no the file is already uploaded to a URL on AWS. So a path is great
davesargent 14 days ago
awarded to weslly

Crowdsource coding tasks.

2 Solutions

Winning solution

This should work

// download the zip file
file_put_contents("", fopen("http://someurl/", 'r'));

// set the API Token
$api_token = "APITOKEN";

// initialise the curl request
$request = curl_init("https://". $api_token ."");

// send a file
curl_setopt($request, CURLOPT_POST, true);
      'file' => '@' . realpath(''),
      'platform'=> 'ios'

// output the response
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($request);

// close the session

great can you remove the zip after uploading please
davesargent 14 days ago
updated the code
weslly 14 days ago
you beat me to it :P
Subhash Dasyam 14 days ago
Cool thanks :)
davesargent 14 days ago
Cool thanks :) I'm testing now and I will award within the next 30 minutes
davesargent 14 days ago
Sorry to be a pain can the results should return a json file { "publicKey": "p7nww3n6ubq73r1nh9jtauqy8w", "created": "2016-02-10T17:46:14.089Z", "updated": "2016-02-10T17:46:14.089Z", "platform": "ios", "versionCode": 1 } Can you tell me where I can access this is it echo curl_exec($request); $results = echo curlexec($request); $rows = jsondecode($results,true); echo $row['publicKey']; Will this work?
davesargent 14 days ago
@weslly not trying to hijack this thread or solution, @davesargent I have added your new request in separate solution :). To display Public Key and all Keys. Do test it :)
Subhash Dasyam 14 days ago
@davesargent sorry, I didn't see the comment earlier, thank you for the award :)
weslly 13 days ago

Based on Weslly code,

++ Added decode of Json code in this php

Hey Thanks for the input :)
davesargent 14 days ago
Thanks for Tipping me :) @davesargent
Subhash Dasyam 14 days ago
It wasn't much sorry but happy new year to you & thanks for the help :D
davesargent 14 days ago
No that's more than enough :) i am sorry i wasn't fast enough to write the solution. thanks for tipping me that's more than enough. Thanks Dave
Subhash Dasyam 13 days ago
View Timeline