2012-06-19 2 views
0

내 웹 사이트에 이미지를 업로드하려면 Flash를 얻어야합니다.플래시 웹 페이지에 이미지 업로드

웹 사이트가 정상적으로 작동하며 간단한 HTML을 업로드하여 작동하도록 할 수 있습니다.

하지만 플래시로 이미지를 웹 사이트에 게시하려면 어떻게해야합니까?

여기에 내 작은 FileSaver 클래스를 다운로드하고 그것의 도움으로 당신은 서버에 저장하고 또한 로컬에 저장할 수있는 현재의 액션을

public function encodeAndSave() 
{ 
var bmd : BitmapData = new BitmapData(300, 300, true, 0xFFFFFFFF); 


// draw the bitmapData from the captureContainer to the bitmapData object; 
bmd.draw(index.avatarMC, new Matrix(), null, null, null, true); 


// create a new JPEG byte array with the adobe JPEGEncoder Class; 
var byteArray : ByteArray = new JPGEncoder(90).encode(bmd); 


var date:Date = new Date(); 
var req:URLRequest = new URLRequest("http://bt.ind-igo.co.uk/test/SaveImage"); 


var params:URLVariables = new URLVariables(); 
params.file= Base64.encode(byteArray); 


params.name = "MyImage.jpg"; 
req.method = URLRequestMethod.POST; 
req.data = params; 
var ldr:URLLoader = new URLLoader(req); 


ldr.addEventListener(Event.COMPLETE, complete); 


ldr.load(req); 


function complete(e:Event):void 
{ 
navigateToURL(new URLRequest("?" + Math.random()), "_self"); 


} 
+0

대해 FileReference.upload (URL)를 사용하지 않는 이유가 있나요? –

답변

0

입니다! http://www.myflashlab.com/2010/02/21/filesaver-data-transfer/

import com.doitflash.tools.fileSaver.FileSaver; 
import com.doitflash.tools.fileSaver.FileSaverConst; 
import com.doitflash.events.FileSaverEvent; 

// if we're saving to server 
var _fileSaver:FileSaver = new FileSaver(); 
_fileSaver.method = FileSaverConst.SERVER; 

// by default the encryption is turned off. if you are turning it on, 
// make sure to put a key for your encryption which is not longer than 8 characters. 
// to deal with encrypted data on your server side script, refer to http://code.google.com /p/as3crypto/ 
//_fileSaver.encrypt(true, "TESTTEST"); 
_fileSaver.encrypt(false); 
_fileSaver.gateway = "phpProcessor.php"; 

// save all parameters that you want to send out in an object like below. 
_fileSaver.vars = {var1:"value1",var2:"value2"}; 

// you may also wish to add a listener to receive the server script respond! 
_fileSaver.addEventListener(FileSaverEvent.RESPOND, onRespond); 

// call the save method and pass the file byteArray to it along with its name like below. 
_fileSaver.save(_byte, "filename", ".gif"); 

function onRespond(e:FileSaverEvent):void 
{ 
    trace(e.paramURLVars) // paramURLVars is of type URLVariables 
    trace(e.paramOBJVars) // paramOBJVars is of type Object 

    // OR 

    trace(_fileSaver.theRespond);// theRespond is of type URLVariables 
    trace(_fileSaver.theRespondObject);// theRespondObject is of type Object 
} 
관련 문제