在服务器映像html2canvas上传

问题描述 投票:0回答:1

enter image description here我有这个js:

$.ajax({
   url: 'ajaxfile.php',
   type: 'POST',
   data: {
        image: base64URL
   },
   success: function(data){
       console.log(data);
       $.notify("info", "Upload successfully");
   },
   error: function () {
       $.notify("Error on image upload");
   }
});

PHP代码:

<?php
  $image = $_POST['image'];
  $location = "src/upload/";
  $image_parts = explode(";base64,", $image);
  $image_base64 = base64_decode($image_parts[1]);
  $filename = "screenshot_".uniqid().'.png';
  $file = $location . $filename;
  file_put_contents($file, $image_base64);
  return [
     'status' => true
  ]
?>

调用已完成(我在浏览器控制台中看到)但在console.log上我返回了代码php。似乎什么都没发生,代码php没有实现。你有个主意吗? Thx提前和抱歉我的英语

我把错误的图像放了

php jquery jquery-ui nginx html2canvas
1个回答
0
投票

qazxsw poi在失败时返回qazxsw poi,因此您可以将其分配给变量并使用它来确定您的状态,如下所示:

file_put_contents()
© www.soinside.com 2019 - 2024. All rights reserved.