uLoader = new URLLoader();
jpgEncoder = new JPGEncoderIMP(80);
request = new URLRequest(this.uploadURL + "?uid=" + this.uidStr + "&sid=" + this.sidStr + "&albumId=" + this.uploadFileWin.combo_photoList.value + "&mark=" + encodeURI(this.uploadFileWin.txt_uploadName.text));
[color=red] request.contentType = "application/octet-stream";
request.data = jpgEncoder.encode(this.bm_main.bitmapData);[/color]
request.method = URLRequestMethod.POST;
uLoader.dataFormat = URLLoaderDataFormat.BINARY;
uLoader.addEventListener(Event.COMPLETE, this.upLoadPicComplete);
uLoader.addEventListener(IOErrorEvent.IO_ERROR, this.upLoadPicError);
uLoader.addEventListener(ProgressEvent.PROGRESS, this.upLoadPicErrorProgress);
uLoader.load(request);
在php端
//读取falsh请求内容,生成图片
$pic = file_get_contents("php://input");
$f = fopen($filename,"wb");
fwrite($f,$pic);
fclose($f);
//post参数赋值
$post_data = array();
$post_data['action'] = "savePhoto";
$post_data['image'] = '@'.realpath($filename);
$post_data['title'] = $_GET['mark'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL,"http://xxx.com/api/photos_write.php");
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, $result);
$result = curl_exec($ch);