Javascriptdocument.getElementById("input1").value=canvas.toDataURL('image/png');代碼處理.php $data = $_POST["input1"]; $data = str_replace('data:image/png;base64,', '', $data); $data = str_replace(' ','+',$data); $data = base64_decode($data);php: <form action="codetreatment.php" method="post"> <input type="text" name="input1" id="input1" > <button type="submit" name="treatmenthistoryupdatebtn" class="btn btn-primary">Save</button></form>但是這個(gè)數(shù)據(jù)庫(kù)代碼不起作用。將畫(huà)布圖像轉(zhuǎn)換為 base64 字符串后的下一步是什么?我想保存到數(shù)據(jù)庫(kù)
1 回答

慕森王
TA貢獻(xiàn)1777條經(jīng)驗(yàn) 獲得超3個(gè)贊
數(shù)據(jù)庫(kù)
$data = $_POST["input1"];
$data = explode(",", $data)[1];
$decoded_image = base64_decode($data);
$temp_name = 'http://your-domain.com/folder/'.md5(time().rand().time()).".png";
file_put_contents($temp_name, $decoded_image);
// Store this $file to table.
$file = basename($temp_name);
- 1 回答
- 0 關(guān)注
- 99 瀏覽
添加回答
舉報(bào)
0/150
提交
取消