file_put_contents 和php://input 实现存储数据进图片中

<?php

/**
 *Recieve p_w_picpath data
 **/
error_reporting(E_ALL);

function get_contents()
{
    $xmlstr = file_get_contents("php://input");
    $filename = time() . '.png';
    if (file_put_contents($filename, $xmlstr)) {//将数据存储进图片格式中
        echo 'success';
    } else {
        echo 'failed';
    }
}

//get_contents();

var_dump(file_get_contents('1565341389.png'));  //读取图片,获取图片中的数据

die();

  

猜你喜欢

转载自www.cnblogs.com/lxwphp/p/11328473.html