1
javascript函數調用HTML2畫布元素scrrenshot的目標DIV要更改保存圖像文件夾的路徑?如何做到這一點
<script type="text/javascript">
function capture() {
$('#target').html2canvas({
onrendered: function (canvas) {
//Set hidden field's value to image data (base-64 string)
$('#img_val').val(canvas.toDataURL("image/png"));
//Submit the form manually
document.getElementById("myForm").submit();
}
});
}
</script>
PHP代碼
<?php
//Get the base-64 string from data
$filteredData=substr($_POST['img_val'], strpos($_POST['img_val'], ",")+1);
//Decode the string
$unencodedData=base64_decode($filteredData);
//echo $unencodedData;
//Save the image
$date = date_create();
$timestamp= date_timestamp_get($date);
echo $timestamp;
$rand = mt_rand(100000,999999);
echo $rand;
$string = "cp-string";
echo $string;
$name = "$string.$timestamp.$rand.png";
//$name = "$string/$timestamp/$rand.png";
//$unencodedData = "$string/$timestamp/$rand";
file_put_contents($name , $unencodedData);
?>
不知道如何給出不同的文件夾路徑來保存圖像
人PLZ告訴我這個東西 –