Php + curl sends Image Processing code sharing ,. Php + curl send Image Processing code sharing, upload page code $ url192.168.1.100upload. php; # you can get the corresponding parameter $ file $ path .. $ Icon; the php + curl file to be uploaded sends Image Processing code sharing,
// Upload 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 Image resources
Date_default_timezone_set ('Asia/Shanghai'); // Set 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 ') {$ ip = geten V ('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 '; // IP address requested by your certificate. 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 ();}
The above is all the content of this article. I hope you will like it.
Http://www.bkjia.com/PHPjc/1029601.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1029601.htmlTechArticlephp+curl sends Image Processing code share, // upload page code $ url = "http: // 192.168.1.100/upload. phplang = cn "; # you can get the corresponding parameter $ file = $ path. '/'. $ Icon; // the text to be uploaded...