Skip to content

Commit

Permalink
If file exists locally use curl_file_create() instead of @filename (w…
Browse files Browse the repository at this point in the history
…hich is deprecated)
  • Loading branch information
electblake committed Aug 11, 2013
1 parent 0ad2a66 commit 1bf619c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Uploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,14 @@ public static function call_api($action, $params, $options = array(), $file = NU
*/
if ($file) {

if (!preg_match('/^@|^https?:|^s3:|^data:[^;]*;base64,([a-zA-Z0-9\/+\n=]+)$/', $file)) {
$post_params["file"] = "@" . $file;
} else {
if (file_exists($file))
{
$post_params['file'] = curl_file_create($file);
}
else if (!preg_match('/^@|^https?:|^s3:|^data:[^;]*;base64,([a-zA-Z0-9\/+\n=]+)$/', $file))
{
$post_params["file"] = "@" . $file;
}
}

curl_setopt($ch, CURLOPT_POST, true);
Expand Down

0 comments on commit 1bf619c

Please sign in to comment.