php保存二進制原始數(shù)據(jù)為圖片的程序代碼
來源:易賢網(wǎng) 閱讀:807 次 日期:2014-10-24 15:49:23
溫馨提示:易賢網(wǎng)小編為您整理了“php保存二進制原始數(shù)據(jù)為圖片的程序代碼”,方便廣大網(wǎng)友查閱!

得到post過來的二進制原始數(shù)據(jù),選擇一個生成路徑及圖片的名字,之后寫入,思路很顯而易見

//生成圖片

$imgdir = 'uploadimg/';

$filename=nissangcj.$mobile..jpg;///要生成的圖片名字

$xmlstr = $globals[http_raw_post_data];

if(empty($xmlstr)) {

$xmlstr = file_get_contents('php://input');

}

$jpg = $xmlstr;//得到post過來的二進制原始數(shù)據(jù)

if(empty($jpg))

{

echo 'nostream';

exit();

}

$file = fopen(./.$imgdir.$filename,w);//打開文件準備寫入

fwrite($file,$jpg);//寫入

fclose($file);//關(guān)閉

$filepath = './'.$imgdir.$filename;

//圖片是否存在

if(!file_exists($filepath))

{

echo 'createfail';

exit();

}

更多信息請查看IT技術(shù)專欄

更多信息請查看網(wǎng)絡編程
易賢網(wǎng)手機網(wǎng)站地址:php保存二進制原始數(shù)據(jù)為圖片的程序代碼
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點

版權(quán)所有:易賢網(wǎng)