將ByteArray 物件傳給PHP 存檔

      Flash 2006-12-10 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);
}
?>
---
标签集:TAGS:
回复Comments() 点击Count()

回复Comments

{commentauthor}
{commentauthor}
{commenttime}
{commentnum}
{commentcontent}
作者:
{commentrecontent}

注册5D通行证,立刻拥有自己的博客发表留言

用户:  密码: 匿名
内容:
加粗 下划线 文本颜色 居中 插入链接 建立Google搜索链接 插入图片 引用文本
 
汗 喜欢 骄傲的笑 哭 酷! 愤怒 黑线 什么? 猥琐 偷笑 无语 晕 吃惊 诱惑
smile frown redface biggrin wink rolleyes mad eek 禁止笑脸转换
zoom inzoom out
验证: checkcode 换一个