PHP CURL by uploading files to another server

// Create a cURL handle 
$ ch = curl_init ( 'destination address');
// create a CURLFile objects
// no longer be uploaded by the @ symbol php5.5 later version, you need this way or new \ CURLFile () objects can be given three parameters for the following parameters, you can copy the code yourself test, it is feasible to
$ file = curl_file_create ($ _ FILES [$ name] [ 'tmp_name'], $ _ FILES [$ name] [ ' type '], $ _ the FILES [$ name] [' name ']);
// set the POST data
$ data = [' File '=> $ File];
curl_setopt ($ CH, CURLOPT_POST,. 1);
curl_setopt ($ CH, CURLOPT_POSTFIELDS, $ Data);
// handle performed
$ Result = the curl_exec ($ CH);
curl_close ($ CH);
var_dump ($ Result); Die;
herein form by an analog front end rear upload method

Guess you like

Origin www.cnblogs.com/kevinggk/p/12001288.html