I have a FileReference object that isn’t firing Complete and Progress events. The upload is successful and it does fire Select and Open events. The only time Complete events fired was when I had an error in my .php and the upload wasn’t successful.
Here is the .as
//curClient contains the fileReference object (fileRef) as well as the browse and upload functions.
private function uploadLogo():void
{
curClient.browser();
curClient.fileRef.addEventListener(Event.SELECT,logoSelect);
curClient.fileRef.addEventListener(Event.OPEN,logoOpen);
curClient.fileRef.addEventListener(Event.COMPLETE,logoComplete);
curClient.fileRef.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA,logoCompleted);
curClient.fileRef.addEventListener(ProgressEvent.PROGRESS,logoProgress);
curClient.fileRef.addEventListener(SecurityErrorEvent.SECURITY_ERROR,securityErrorHandler);
curClient.fileRef.addEventListener(IOErrorEvent.IO_ERROR,ioErrorHandler);
}
public function logoOpen(event:Event):void
{
trace("logo open event " + event.target.name);
}
public function logoProgress(event:ProgressEvent):void
{
var file:FileReference = FileReference(event.target);
trace("progressHandler: name=" + file.name + " bytesLoaded=" + event.bytesLoaded + " bytesTotal=" + event.bytesTotal);
logoProgBar.setProgress(event.bytesLoaded,event.bytesTotal);
}
public function logoComplete(event:Event):void{
trace("logo complete " + event.target);
curClient.logoUploadComplete();
logoVal.label = event.target.name;
logoProgBar.visible = false;
}
and here is the php i’m using to manage the upload. this code is working fine, but do I need to include something to share the progress, complete events with the .swf?
<?php
$stamp = $_GET["stamp"];
if(!is_dir('../../data/images/'.$stamp)) mkdir('../../data/images/'.$stamp,0755);
if(!is_dir('../../data/images/'.$stamp.'/logo')) mkdir('../../data/images/'.$stamp.'/logo',0755);
if ($_FILES['Filedata']['name']) {
move_uploaded_file($_FILES['Filedata']['tmp_name'], '../../data/images/'.$stamp.'/logo/'. basename($_FILES['Filedata']['name']));
}
?>