Apache flex 在Flex2中上传时如何获取文件的字节数组
现在,我使用flex 2&执行以下操作:Apache flex 在Flex2中上传时如何获取文件的字节数组,apache-flex,Apache Flex,现在,我使用flex 2&执行以下操作: There is a WSDL which have one method which take byteArray & fileName(which i want to write) as a parameter to write a file in local system, the following is the code... public void writeLocation(byte[] byteToWrite, Str
There is a WSDL which have one method which take byteArray & fileName(which i want to write) as a parameter to write a file in local system, the following is the code...
public void writeLocation(byte[] byteToWrite, String fileName) throws FileNotFoundException
{
StringBuffer fileLocation = new StringBuffer("D:\\Products\\Device");
fileLocation.append("\\"+fileName);
File file = new File(fileLocation.toString());
BufferedOutputStream bufferWriter = new BufferedOutputStream(new FileOutputStream(file));
try
{
bufferWriter.write(byteToWrite);
}
catch (IOException e)
{
System.out.println("Error file Writing....");
e.printStackTrace();
}
finally
{
try
{
bufferWriter.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
但是当我搜索时显示错误的Flex2我在Flex2中发现没有“数据”属性。因此,我无法将所选对象创建到byteArray中。。有人能帮我怎么做吗不想使用HTTPService(POST方法)
请帮忙。。提前感谢该功能在FP 9中不可用。你需要这样做 但是,这是为Flex3设计的,因此它可能适用于框架的旧版本,也可能不适用于框架的旧版本。无论哪种方式,问题是您使用的功能在您使用的版本中不可用
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:WebService id = "byteCheckUpload" wsdl="http://localhost:8080/XFireTest/xfire/EmployeeService?wsdl" showBusyCursor="true">
<mx:operation name="writeLocation" fault="writeLocationFH(event)" result="writeLocationRH()"/>
<mx:WebService/>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
private var refUploadFile : FileReference;
public function uploadFile() : void
{
refUploadFile = new FileReference();
refUploadFile.browse();
refUploadFile.addEventListener(Event.SELECT,onFileSelect);
refUploadFile.addEventListener(Event.COMPLETE,onFileComplete);
}
public function onFileSelect(event : Event) : void
{
refUploadFile.load();
}
public function onFileComplete(event : Event) : void
{
refUploadFile = event.currentTarget as FileReference;
var data:ByteArray = new ByteArray();
refUploadFile.data.readBytes(data,0,refUploadFile.data.length);
byteCheckUpload.writeLocation(data, refUploadFile.name)
}
public function writeLocationFH(event : FaultEvent) : void
{
Alert.show(event.fault.faultString);
}
public function writeLocationRH() : void
{
Alert.show("Please check the Location .... !!!");
}
]]>
</mx:Script>
<mx:Button x="308" y="156" label="Click button to Upload a file" click="uploadFile();"/>