將ByteArray 物件傳給PHP 存檔

      Flash 2006-12-10 14:31:00

来源:http://www.riarock.com/

ByteArray 物件可以透過 URLRequest 物件傳給後端
---

_btn.addEventListener(MouseEvent.MOUSE_UP, myMouseUp);
function
myMouseUp(e:Event){
var
req:URLRequest = new URLRequest("test_request.php");
req.data = byte_array_data;
req.method = URLRequestMethod.POST;
req.contentType = 'application/octet-stream';
flash.net.navigateToURL(req, "_blank");
}
---
若使用 PHP
---
<?php
$ data = $ GLOBALS['HTTP_RAW_POST_DATA'];
if
(is_null($ data)) {
echo "No data was sent";
}
else {
$ file = fopen("test.jpg", "w") or die("Can't open file");
if
(!fwrite($ file, $ data)){
echo "Error writing to file";
}

print
"OK\n";
fclose($ file);
}
?>
---
标签集:TAGS:
回复Comments() 点击Count()
喜欢就顶一下

回复Comments

{commentauthor}
{commentauthor}
{commenttime}
{commentnum}
{commentcontent}
作者:
{commentrecontent}
深度XP 雨林木风XP WinXP下载 世界之窗 深度系统 雨林木风 Ghost ghost系统盘 XP下载