Hi all,
I am new to flash and ActionScript 3.0. I need help on File uploading.
My flash file contains a Textfield(with name “upload_txt”, which is used to mention the file to be uploaded) and a Button(“Submit_btn”, which uploads the mentioned file).
When we are trying to upload the file("onSubmit_Click" event) occurs, the code looks like this:
import flash.net.FileReference;
import flash.net.FileFilter;
upload_txt.border=true;
var url:String = "http://localhost:8080/SampleApplication1/attachment";
var req:URLRequest = new URLRequest(url);
//var urlrequest:URLRequest("");
var imageTypes:FileFilter = new FileFilter("Images (*.jpg, *.jpeg, *.gif, *.png)", "*.jpg; *.jpeg; *.gif; *.png");
var textTypes:FileFilter = new FileFilter("Text Files (*.txt, *.rtf)", "*.txt; *.rtf");
var allTypes:Array = new Array(imageTypes, textTypes);
var fileRef:FileReference = new FileReference();
fileRef.addEventListener(Event.SELECT, selectHandler);
function selectHandler(event:Event):void {
upload_txt.text=fileRef.name;
var variables:URLVariables = new URLVariables();
variables.attachment=upload_txt.text;
req.data = variables;
}
browse_mc.addEventListener(MouseEvent.CLICK,onUploadbtn);
function onUploadbtn(evnt:MouseEvent):void {
fileRef.browse(allTypes);
}
submit_mc.addEventListener(MouseEvent.CLICK,onSubmit_Click)
function onSubmit_Click(evnt:MouseEvent):void
{
fileRef.upload(req); //Line of Code for File Uploading
}
Also, we are getting an error message for the above code as:
** Error #2044: Unhandled IOErrorEvent:. text=Error #2038: File I/O Error.
at sampleupload_fla::MainTimeline/sampleupload_fla::frame1() **
So, please help me in this context.
Also, When browsing for files using ** “fileRef.browse(allTypes);” ** in the above code, we get only the “file-name”. But, we require the absolute path including the filename.
Please help regarding this query…
It’s urgent…
Waiting for reply…
Thanx a lot in advance…
Srihari.Ch