[英]html2canvas cannot convert and upload 1mb < size image in php server
我正在使用html2canvas div將圖像轉換為圖像,然后將圖像發布到php,此過程僅在700kb以下的圖像中執行,700kb <大小的圖像無法在php中發布。 請提供一些想法和示例代碼。
我的html代碼是:
<div id="popup_div">
<h1>i put some special</h1>
</div>
<form method="POST" enctype="multipart/form-data" action="work_cards.php" id="myForm">
<input type="hidden" name="img_val" id="img_val" value="" />
</form>
我的查詢:
function capture() {
$('#popup_div').html2canvas({
useCORS: true,
allowTaint: true,
onrendered: function (canvas) {
//Set hidden field's value to image data (base-64 string)
$('#img_val').val(canvas.toDataURL("image/jpeg").replace("image/jpeg", "image/octet-stream"));
//Submit the form manually
document.getElementById("myForm").submit();
}
});
}
work_cards.php代碼是:
$filteredData=substr($_POST['img_val'], strpos($_POST['img_val'], ",")+1);
//Decode the string
$unencodedData=base64_decode($filteredData);
$url = "Kings_design";
//Save the image
file_put_contents('img/order/'.$url.'.jpeg', $unencodedData);
echo $_POST['img_val'];
將php.ini
的post_max_size
的值設置為大於1 MB,
post_max_size="4M"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.