后xmlHTT prequest发送从PHP $ _ POST访问ArrayBuffer() [英] Accessing ArrayBuffer from PHP $_POST after xmlHTTPrequest send()

查看:140
本文介绍了后xmlHTT prequest发送从PHP $ _ POST访问ArrayBuffer()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是从下面的XMLHtt prequest 2学费:

I'm following the tuitions on XMLHttpRequest 2 from :

https://developer.mozilla.org/en/DOM/XMLHtt$p$pquest/Sending_and_Receiving_Binary_Data http://www.html5rocks.com/en/tutorials/文件/ xhr2 /#TOC-发送-arraybuffer

这是给客户端伟大的教程,这里是从我的脚本工作摘录:

They're great tutorials for the client side, and here is a working extract from my script:

var imagebuffer = new ArrayBuffer(size);  // create the readonly memory buffer
var imagedata= new Uint8Array(imagebuffer); // create a view to manipulate data

//做一些很酷的东西用的ImageData

var exchange=new XMLHttpRequest();
exchange.open("POST",url,true);
exchange.send(arraybuffer);

到目前为止好,我可以从大量的数据被传输的客户端和服务器的控制面板看到的。

So far so good, and I can see from the both client and server control panels that plenty of data is being transferred.

下面是我的问题:我怎么访问ArrayBuffer与PHP的服务器? 我已习惯使用全局变量$ _POST想要的参数从HTML表单传递,因此它可以被作为一个数组访问,但我找不到如何进入这个二进制数组,并把它贴在我的MySQL数据库中的任何引用。

Here's my problem: how do I access the ArrayBuffer with PHP at the server? I'm used to the $_POST superglobal wanting parameters passing from a HTML form so it can be accessed as an array but I can't find any reference for how to access this binary array and stick it in my MySQL database.

推荐答案

好了 - 我已经想通了。我的服务器端PHP打开与:

Okay - I've figured it out. My server side PHP opens with:

$data=file_get_contents('php://input');
$mysql_blob=base64_encode($data);

这是现在的格式准备插入(例如)到MySQL作为BLOB格式。

which is now in a format ready for inserting (for example) into MySQL as a BLOB format.

工程就像一个魅力!

这篇关于后xmlHTT prequest发送从PHP $ _ POST访问ArrayBuffer()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆