Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 通过jquery上传到数据URL图像_Php_Jquery_Canvas_Kineticjs - Fatal编程技术网

Php 通过jquery上传到数据URL图像

Php 通过jquery上传到数据URL图像,php,jquery,canvas,kineticjs,Php,Jquery,Canvas,Kineticjs,我正在尝试从画布中创建一个图像,但经过一些尝试后,我似乎无法在后端获得一个工作上传的PNG。有人能看看这里发生了什么吗 我的javascript: stage.toDataURL({ callback: function(dataUrl) { var imgURL = dataUrl; // keep the entire url $.ajax({ type: "POST", url: "http:/

我正在尝试从画布中创建一个图像,但经过一些尝试后,我似乎无法在后端获得一个工作上传的PNG。有人能看看这里发生了什么吗

我的javascript:

    stage.toDataURL({
    callback: function(dataUrl) {
        var imgURL = dataUrl; // keep the entire url
        $.ajax({
            type: "POST",
            url: "http://www.xxxx.nl/pointer/upload.php", 
            data: ({imgData : imgURL}),
            cache: false,
            success: function(result){
                //window.open(dataUrl); // Show result stage in a new window
                alert(result); // show php error if exists
            }
        });
    }
});
现在我的真正的basic.php:

$im = imagecreatefrompng($_POST['imgData']);
header('Content-Type: image/png');
imagepng($im);
imagedestroy($im);
我的错误日志:

[Fri Mar 08 11:29:16 2013] [error] [client 24.132.214.139] mod_security: Access denied with code 500. Error reading request body, error code 70007: The timeout specified has expired [hostname "www.ccc.nl"] [uri "/pointer/upload.php"] 
执行此操作时:

var canvasData = myCanvas.toDataURL("image/png");
您将获得表示.png的base64编码字符串,如下所示:

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAAEsCAYAAAB5fY51AAAGB………
请注意,此字符串的前缀为:data:image/png;base64。.png文件不需要/无法识别此标头,并且弄脏了imagecreatefrompng()。因此,当保存此字符串以创建.png时,必须去掉标题。在php端,您可以这样做(尽管您也可以在客户端将其剥离):

然后正常继续…

执行此操作时:

var canvasData = myCanvas.toDataURL("image/png");
您将获得表示.png的base64编码字符串,如下所示:

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAAEsCAYAAAB5fY51AAAGB………
请注意,此字符串的前缀为:data:image/png;base64。.png文件不需要/无法识别此标头,并且弄脏了imagecreatefrompng()。因此,当保存此字符串以创建.png时,必须去掉标题。在php端,您可以这样做(尽管您也可以在客户端将其剥离):


然后正常继续…

您的JavaScript代码非常好。在PHP方面,您可以只使用随附的。记录在案。或者,您可以查找它的源代码。您的JavaScript代码非常好。在PHP方面,您可以只使用随附的。记录在案。或者,您可以查找其源代码。