Uploads file using Curl

Returns response after upload.

php
fork add to bundle source
function curl_upload($url, $file_path) { if (function_exists('curl_file_create')) { $curl_file = curl_file_create($file_path); } else { $curl_file = '@' . realpath($file_path); } $file_name = basename($file_path); $ch = curl_init($url); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => [$file_name=> $curl_file] ]); return curl_exec($ch); }

usage

load_function('curl_upload'); echo curl_upload('https://bashupload.com/', '/tmp/file.txt'); // ...
← how to use this in app?
create log ...inout