This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Flex and the fly likes File uploading in flex Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Frameworks » Flex
Reply 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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: File uploading in flex
 
Similar Threads
Anybody worked on Adobe Flex
Picture upload from flex RIA to MySql using java
How to call JSP page from Flex
How to call the creationComplete() method each time I visit the Flex state
having components based on Data Grid's column value.