您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php接收二进制流

2025/6/27 10:53:18发布13次查看
/** 二进制流生成文件
    * $_post 无法解释二进制流,需要用到 $globals['http_raw_post_data'] 或 php://input
    * $globals['http_raw_post_data'] 和 php://input 都不能用于 enctype=multipart/form-data
    * @param    string  $file   要生成的文件路径
    * @return   boolean
    */
    function binary_to_file($file){
        $content = $globals['http_raw_post_data'];  // 需要php.ini设置
        if(empty($content)){
            $content = file_get_contents('php://input');    // 不需要php.ini设置,内存压力小
        }
        $ret = file_put_contents($file, $content, true);
        return $ret;
    }
binary_to_file('photo/test.png');
以上就介绍了php接收二进制流,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product