2006/12/10 | 將ByteArray 物件傳給PHP 存檔
类别(Flash) | 评论(0) | 阅读(448) | 发表于 14:31

来源: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);
}
?>
---
0

评论Comments

日志分类
首页[186]
Flash[84]
FMS[41]
AIR[2]
ASP[11]
作品区[12]
其他[36]