moving helper functions to scripts folder
This commit is contained in:
1 parent
e7fad500f9
commit
dc39b6988c
9 files changed
+525
-60
No files matched your search
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
require_once __DIR__.'/config.php';
|
||||
|
||||
function uploadPhotos($provider_id, $files) {
|
||||
$url = BASE_API_URL . "/api/providers/$provider_id/photos";
|
||||
|
||||
$c = curl_init($url);
|
||||
curl_setopt($c, CURLOPT_POST, true);
|
||||
curl_setopt($c, CURLOPT_HTTPHEADER, ['Content-Type: multipart/form-data']);
|
||||
// Build multipart array
|
||||
$multipart = [];
|
||||
foreach ($files['tmp_name'] as $i => $tmp) {
|
||||
$multipart[] = [
|
||||
'name' => 'photos',
|
||||
'contents' => fopen($tmp, 'r'),
|
||||
'filename' => $files['name'][$i],
|
||||
];
|
||||
}
|
||||
curl_setopt($c, CURLOPT_POSTFIELDS, $multipart);
|
||||
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
$res = curl_exec($c);
|
||||
$http = curl_getinfo($c, CURLINFO_HTTP_CODE);
|
||||
curl_close($c);
|
||||
|
||||
return $http < 400 ? json_decode($res, true) : null;
|
||||
}
|
||||
?>
|
||||
Reference in new issue
Block a user