Uploading image Into The $_FILES Without A Form
- by user1799825
How to upload image from another server into the array $ _FILES [] without form ‹input type="file" name="file" /› with the creation of a temporary file in / TMP.
It is necessary to the script api.php:
<? php
function doPost ($ sMethod, $ aPost = array ())
{
$ aPost ['method'] = $ sMethod;
$ aPost ['token'] = APP_TOKEN;
$ hCurl = curl_init ();
curl_setopt ($ hCurl, CURLOPT_URL, APP_URL. 'api.php');
curl_setopt ($ hCurl, CURLOPT_HEADER, false);
curl_setopt ($ hCurl, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ hCurl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt ($ hCurl, CURLOPT_POST, true);
curl_setopt ($ hCurl, CURLOPT_POSTFIELDS, $ aPost);
$ sData = curl_exec ($ hCurl);
curl_close ($ hCurl);
}
?>