I am having trouble for this work.
I want to save a image to live server which I get base64 data. when I use localhost that's fine to work. But when I use live server using hosting it seems wrong.
Hosting file uploading size 138 MB now. What could I do know.
Thanks.
my code:
$("#btn-save").on('click', function() {
html2canvas($(".canvas-container"), {
onrendered: function(canvas) {
var imgData = canvas.toDataURL('image/jpeg');
$.ajax({
url:'save.php',
type:'post',
dataType: "json",
data:{
base64data:imgData
},
success: function (data) {
showToast(data.status, data.message);
},
error: function (error) {
showToast("error", 'Failed to save!');
}
});
}
});
});
php code:
$data = $_REQUEST['base64data'];
$title = $_REQUEST['title'];
$image = explode('base64,', $data);
$file = 'images/'. time(). '.jpg';
file_put_contents($file, base64_decode($image[1]));
mysqli_query($connect,"INSERT INTO img_tbl (title, image) values ('$title', '$file')");
oky, thanks all, i found it, it's problem in my hosting . my hosting is so much disgusting that's why i faced this problem. when i change my hosting and work properly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.