luke_the_duke 가 포스팅한 방법이다.
원문function sendJPG (bmpData: BitmapData): void {
//Converting BitmapData into a JPEG-encoded ByteArray var jpgObj: JPGEncoder = new JPGEncoder(100); var imageBytes: ByteArray = jpgObj.encode (bmpData); imageBytes.position = 0; var boundary: String = '---------------------------7d76d1b56035e'; var header1: String = '--'+boundary + '\r\n' +'Content-Disposition: form-data; name="Filename"\r\n\r\n' +'picture.jpg\r\n' +'--'+boundary + '\r\n' +'Content-Disposition: form-data; name="Filedata"; filename="picture.jpg"\r\n' +'Content-Type: application/octet-stream\r\n\r\n' //In a normal POST header, you'd find the image data here var header2: String = '--'+boundary + '\r\n' +'Content-Disposition: form-data; name="Upload"\r\n\r\n' +'Submit Query\r\n' +'--'+boundary + '--'; //Encoding the two string parts of the header var headerBytes1: ByteArray = new ByteArray(); headerBytes1.writeMultiByte(header1, "ascii"); var headerBytes2: ByteArray = new ByteArray(); headerBytes2.writeMultiByte(header2, "ascii"); //Creating one final ByteArray var sendBytes: ByteArray = new ByteArray(); sendBytes.writeBytes(headerBytes1, 0, headerBytes1.length); sendBytes.writeBytes(imageBytes, 0, imageBytes.length); sendBytes.writeBytes(headerBytes2, 0, headerBytes2.length); var request: URLRequest = new URLRequest("http://www.yourdomain.ch/upload.php"); request.data = sendBytes; request.method = URLRequestMethod.POST; request.contentType = "multipart/form-data; boundary=" + boundary; var loader:URLLoader = new URLLoader(); loader.addEventListener(Event.COMPLETE, uploadCompleted); try { loader.load(request); } catch (error: Error) { trace("Unable to load requested document."); } } function uploadCompleted (e: Event) { trace(e.target.data) }
'programming > etc' 카테고리의 다른 글
미친나. Me2Face 소셜 네트워크의 아트 (0) | 2008.11.03 |
---|---|
Creating components in Macromedia Flash MX (0) | 2008.10.28 |
RIA CAMP 2nd in 서울 (0) | 2008.10.01 |
Flash 10 API, Using Nightly version of Flex SDK (0) | 2008.09.24 |
Voxel Graphics !! in Flash (0) | 2008.09.24 |
WRITTEN BY
,