Uploading image Into The $_FILES Without A Form
Posted
by
user1799825
on Stack Overflow
See other posts from Stack Overflow
or by user1799825
Published on 2012-11-05T10:44:56Z
Indexed on
2012/11/05
11:01 UTC
Read the original article
Hit count: 108
php
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);
}
?>
© Stack Overflow or respective owner