-
FileReference class - uploadComplete listener not working
I'm basing this off of the example in the help, but it doesn't seem to be working right. It will show the progress, and it'll even show up till the bytesLoaded = bytesTotal.. but it won't call the complete function when it obviously seems complete! Anyone know what's going on?
Code:
import flash.display.Sprite;
import flash.events.*;
import flash.net.FileFilter;
import flash.net.FileReference;
import flash.net.URLRequest;
var uploadURL:URLRequest;
var file:FileReference;
FileReferenceExample();
function FileReferenceExample() {
uploadURL = new URLRequest();
uploadURL.url = "http://www.bizzark.com/projects/cms/cms-fileupload.php";
file = new FileReference();
file.addEventListener(Event.COMPLETE, completeHandler);
file.addEventListener(ProgressEvent.PROGRESS, progressHandler);
file.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
file.addEventListener(Event.SELECT, selectHandler);
file.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA,uploadCompleteDataHandler);
file.browse(getTypes());
}
function getTypes():Array {
var allTypes:Array = new Array(getImageTypeFilter(), getTextTypeFilter());
return allTypes;
}
function getImageTypeFilter():FileFilter {
return new FileFilter("Images (*.jpg, *.jpeg, *.gif, *.png)", "*.jpg;*.jpeg;*.gif;*.png");
}
function getTextTypeFilter():FileFilter {
return new FileFilter("Text Files (*.txt, *.rtf)", "*.txt;*.rtf");
}
function completeHandler(event:Event):void {
trace("completeHandler: " + event);
}
function uploadCompleteDataHandler(event:Event):void {
trace("uploadCompleteData: " + event);
}
function progressHandler(event:ProgressEvent):void {
var file:FileReference = FileReference(event.target);
trace("progressHandler name=" + file.name + " bytesLoaded=" + event.bytesLoaded + " bytesTotal=" + event.bytesTotal);
}
function securityErrorHandler(event:SecurityErrorEvent):void {
trace("securityErrorHandler: " + event);
}
function selectHandler(event:Event):void {
var file:FileReference = FileReference(event.target);
trace("selectHandler: name=" + file.name + " URL=" + uploadURL.url);
file.upload(uploadURL);
}
-
Registered User
hi,
Tried it locally, submitting to a blank php script and it works fine.
The uploadCompleteData gets triggered.
-
that's weird.. I try it and the only handlers that give output are the selectHandler, and the progressHandler... >.<
-
I'm have the same problem still. Same basic thing going on, different script though.. don't think I ever solved this.
Anyone have any idea why the completeListener may not be getting called?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|