zoukankan      html  css  js  c++  java
  • 2021.2 假期笔记

    // cocos 显示一个图片到 quad 上面
    let material = cc.Material.createWithBuiltin('unlit');
    material.define('USE_DIFFUSE_TEXTURE', true);
    material.setProperty('diffuseTexture', texture2d);
    this.monster.getComponent(cc.MeshRenderer).setMaterial(0, material);
       // php 发送 multipart/form-data 内容
       static function postMultiData($url, $postdata, $files = null)
        {
            $data = "";
            $boundary = "---------------------".substr(md5(rand(0,32000)), 0, 10);
    
            //Collect Postdata
            foreach($postdata as $key => $val)
            {
                $data .= "--$boundary
    ";
                $data .= "Content-Disposition: form-data; name="".$key.""
    
    ".$val."
    ";
            }
    
            $file = $files[0];
            $handle = fopen($file, "rb");//读取二进制文件时,需要将第二个参数设置成'rb'
            //通过filesize获得文件大小,将整个文件一下子读到一个字符串中
            $fileContents = fread($handle, filesize ($file));
            fclose($handle);
    
            p($file);
            p(filesize($file));
    
            $data .= "--$boundary
    ";
            $data .= "Content-Disposition: form-data; name="file"
    
    ".$fileContents."
    ";
    
            $data .= "--$boundary
    ";
    
    
            $arrContextOptions=array(
                "ssl"=>array(
                    "cafile" => self::$pem,
                    "verify_peer"=> true,
                    "verify_peer_name"=> true,
                ),
                'http' => [
                    'method' => 'POST',
                    'header' => 'Content-Type: multipart/form-data; boundary='.$boundary,
                    'content' => $data
                ]
            );
            $r = file_get_contents($url, false, stream_context_create($arrContextOptions));
            return $r;
        }



    医学我的剑,编程我的酒。 仗剑走天涯,偶尔喝喝酒。
  • 相关阅读:
    Java学习总结
    John 尼姆博弈
    博弈知识汇总(转)
    坏习纠正
    QDUOJ 河老师的新年礼物(尺取法)
    HDU
    QDUOJ ycb的ACM进阶之路 二进制多重背包
    HDU
    HDU
    POJ
  • 原文地址:https://www.cnblogs.com/mitang/p/14397147.html
Copyright © 2011-2022 走看看