[英]html2canvas cannot convert and upload 1mb < size image in php server
I am using html2canvas div to images converted, then images post to php, this process is only executed below 700kb images only, 700kb < size images cannot post in php. 我正在使用html2canvas div将图像转换为图像,然后将图像发布到php,此过程仅在700kb以下的图像中执行,700kb <大小的图像无法在php中发布。 Please give some ideas and sample code.
请提供一些想法和示例代码。
my html code is: 我的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>
my query: 我的查询:
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 code is: 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.