aspose file tools*
The moose likes Flex and the fly likes File uploading in flex Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Flex
Bookmark "File uploading in flex" Watch "File uploading in flex" New topic
Author

File uploading in flex

aman thind
Ranch Hand

Joined: Jun 29, 2007
Posts: 71
I have an mxml which i have taken from some website

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" fontSize="12" creationComplete="init()">
<mx:Script>
<![CDATA[
private var fileRef:FileReference;

private const FILE_UPLOAD_URL:String = "http://www.YOUR-WEBSITE-HERE.com/fileref/uploader.cfm";

private function init():void {
fileRef = new FileReference();
fileRef.addEventListener(Event.SELECT, fileRef_select);
fileRef.addEventListener(ProgressEvent.PROGRESS, fileRef_progress);
fileRef.addEventListener(Event.COMPLETE, fileRef_complete);
}

private function browseAndUpload():void {
fileRef.browse();
message.text = "";
}

private function fileRef_select(evt:Event):void {
try {
message.text = "size (bytes): " + numberFormatter.format(fileRef.size);
fileRef.upload(new URLRequest(FILE_UPLOAD_URL));
} catch (err:Error) {
message.text = "ERROR: zero-byte file";
}
}

private function fileRef_progress(evt:ProgressEvent):void {
progressBar.visible = true;
}

private function fileRef_complete(evt:Event):void {
message.text += " (complete)";
progressBar.visible = false;
}
]]>
</mx:Script>

<mx:NumberFormatter id="numberFormatter" />

<mx:Button label="Upload file"
click="browseAndUpload();" />
<mx:Label id="message" />
<mx:ProgressBar id="progressBar"
indeterminate="true"
visible="false" />
</mx:Canvas>


I need to upload a file and call a webservice method and save this file in database. But i am totally new to Flex and don't have a single clue how to achieve this? Can anyone guide me how to achieve this. What should i pass as URL if i need to just save in database?


Aman Thind
SCJP,SCWCD
JAVA utte mar JAVA,mit JAVA
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

You should pass the URL of the server side code you have written to process the uploaded file.

Personally, rather than guessing your way round this code I'd stop what you are doing and take a few days to learn about the basics of Flex. It will be much less painful in the long run.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File uploading in flex
 
Similar Threads
How to call JSP page from Flex
Picture upload from flex RIA to MySql using java
having components based on Data Grid's column value.
How to call the creationComplete() method each time I visit the Flex state
Anybody worked on Adobe Flex