得到post過來的二進(jìn)制原始數(shù)據(jù),選擇一個(gè)生成路徑及圖片的名字,之后寫入,思路很顯而易見
//生成圖片
$imgDir = 'uploadImg/';
$filename="nissangcj".$mobile.".jpg";///要生成的圖片名字
$xmlstr = $GLOBALS[HTTP_RAW_POST_DATA];
if(empty($xmlstr)) {
$xmlstr = file_get_contents('php://input');
}
$jpg = $xmlstr;//得到post過來的二進(jìn)制原始數(shù)據(jù)
if(empty($jpg))
{
echo 'nostream';
exit();
}
$file = fopen("./".$imgDir.$filename,"w");//打開文件準(zhǔn)備寫入
fwrite($file,$jpg);//寫入
fclose($file);//關(guān)閉
$filePath = './'.$imgDir.$filename;
//圖片是否存在
if(!file_exists($filePath))
{
echo 'createFail';
exit();
}
更多信息請(qǐng)查看IT技術(shù)專欄
2025國(guó)考·省考課程試聽報(bào)名