Phpcurl sends Image processing
// Upload the page code $ url = "http: // 192.168.1.100/upload. php? Lang = cn "; # you can get the corresponding parameter $ file = $ path. '/'. $ Icon; // file to be uploaded $ fields ['F'] = '@'. $ file; $ ch = curl_init (); curl_setopt ($ ch, CURLOPT_URL, $ url); curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ ch, CURLOPT_POST, 1); curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ fields); curl_exec ($ ch); if ($ error = curl_error ($ ch) {die ($ error );} curl_close ($ ch );
// Receives the image resource date_default_timezone_set ('Asia/Shanghai'); // sets the time zone $ ip = ''; if (getenv ('http _ CLIENT_IP ') & strcasecmp (getenv ('http _ CLIENT_IP '), 'Unknown') {$ ip = getenv ('http _ CLIENT_IP ');} elseif (getenv ('http _ X_FORWARDED_FOR ') & strcasecmp (getenv ('http _ X_FORWARDED_FOR'), 'Unknown ')) {$ ip = getenv ('http _ X_FORWARDED_FOR ');} elseif (getenv ('remote _ ADDR') & strcasecmp (getenv ('remote _ ADDR '), 'unknown ') {$ I P = getenv ('remote _ ADDR ');} elseif (isset ($ _ SERVER ['remote _ ADDR']) & $ _ SERVER ['remote _ ADDR '] & strcasecmp ($ _ SERVER ['remote _ ADDR'], 'Unknown ')) {$ ip = $ _ SERVER ['remote _ ADDR '];} preg_match ("/[\ d \.] {7, 15}/", $ ip, $ ipmatches); $ ip = $ ipmatches [0]? $ Ipmatches [0]: 'Unknown ';//??? Obtain the IP address and set the whitelist $ date = date ("[Y-m-d H: I: s]"); $ allowip = array ('2017. 168.1.100 '); if (! In_array ($ ip, $ allowip) {$ Marshal = "{$ date} {$ ip} \ n"; file_put_contents ('upload _ ip. log', $ Marshal, FILE_APPEN); die (-1);} // receives the get parameter $ lang = isset ($ _ REQUEST ['Lang '])? $ _ REQUEST ['Lang ']: 'cn'; $ uploaddir = "/data/cdncache/res/gifts/{$ lang}/"; $ uploadfile = $ uploaddir. $ _ FILES ['F'] ['name']; if (move_uploaded_file ($ _ FILES ['F'] ['tmp _ name'], $ uploadfile )) # successfully saved the image {$ type = $ _ FILES ['F'] ['type']; $ tmp_name = $ _ FILES ['F'] ['tmp _ name']; $ error = $ _ FILES ['F'] ['error']; $ size = $ _ FILES ['F'] ['size']; $ log_txt = 'name :'. $ _ FILES ['F'] ['name']. 'type :'. $ type. 'tmp_name :'. $ tmp_name. 'Error :'. $ error. 'Size :'. $ size. "hello ". 'Lang :'. $ _ REQUEST ['Lang ']; $ value = "{$ date} {$ log_txt} \ n"; @ file_put_contents ('upload _ OK. log', $ value, FILE_APPEND); exit ();} else {$ type = $ _ FILES ['F'] ['type']; $ tmp_name = $ _ FILES ['F'] ['tmp _ name']; $ error = $ _ FILES ['F'] ['error']; $ size = $ _ FILES ['F'] ['size']; $ log_txt = 'name :'. $ _ FILES ['F'] ['name']. 'type :'. $ type. 'tmp_name :'. $ tmp_name. 'Error :'. $ error. 'Size :'. $ size. "hello ". 'Lang :'. $ _ REQUEST ['Lang ']; $ value = "{$ date} {$ log_txt} \ n"; @ file_put_contents ('upload _ ng. log', $ value, FILE_APPEND); exit ();}