Php+curl send picture processing code sharing _php Tips

Source: Internet
Author: User
Tags curl set time

Upload page code

  $url = "HTTP://192.168.1.100/UPLOAD.PHP?LANG=CN";  #可以get传相应参数
  $file = $path. ' /'. $Icon; The 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); 

Receive picture Resources

  Date_default_timezone_set (' Asia/shanghai ');
  Set 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 = ge
    Tenv (' http_x_forwarded_for '); }elseif (getenv (' remote_addr ') && strcasecmp (getenv (' remote_addr '), ' unknown ')) {$ip = 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 ';
    Please ask for IP, set whitelist $date = Date ("[Y-m-d h:i:s]");
    $allowip = Array (' 192.168.1.100 ');
        if (!in_array ($ip, $allowip)) {$ipVal = "{$date} {$ip}\n";
     File_put_contents (' Upload_ip.log ', $ipVal, File_appen);   Die (-1); //Receive get reference $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)) #保存图片成功 {$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 the entire contents of this article, I hope you can enjoy.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.