Is there a problem with FileReference and different browser plugins?
Hello, Im having som trouble with a uploding app am making. First of it works great in IE 8(and7) but when i try it in Firefox og Crome it seems to not be able to upload the file complet.
The problem seems to lie with the FileReference. Im jusing a php script in the backend, and when i try to logg it, as I said it works perfektly with IE, but when i use FF or Crome, i get to log the $_FILE, data but nothing ever makes it to the temp folder. I've checked every php and apache logg i can find, and I know there is not a problem with space, og the temp dir. So the only thing I can figure is that the FileRefernce dosent send the complete file in FF and chrom....... I've been googleing and trying to figure out this problem for a couple days now,, and Im starting to go a litle crazy 😉
If anybody can help me with this I would be a happy camper... sorry for my bad englis, it's not my native toung....
-Jc
Im pasting in the complete kode im using her :
import fl.events.*;
import flash.events.*;
import flash.net.FileReference;
import flash.net.FileReferenceList;
var selectedFileArray:Array = []; /* Inneholde listenmed filnavn */
var fileRefList:FileReferenceList = new FileReferenceList();
// Event listeners
ButtonBrows.addEventListener(MouseEvent.CLICK, clickBrowsForFiles);
fileRefList.addEventListener(Event.SELECT, selectHandler);
ButtonEmtyList.addEventListener(MouseEvent.CLICK, clickEmtyList);
ButtonRemoveElement.addEventListener(MouseEvent.CLICK, clickRemoveSelectedItems);
ButtonUploadFiles.addEventListener(MouseEvent.CLICK, clickUploadFiles);
// Start
DisableButtons();
// Functions
function clickBrowsForFiles(eventObj:MouseEvent):void{
fileRefList.browse();
}
function selectHandler(event:Event):void{
var files:FileReferenceList = FileReferenceList(event.target);
selectedFileArray = files.fileList;
var item:FileReference;
for(var i:Number = 0; i < selectedFileArray.length; i++) {
item = selectedFileArray;
trace("name: " + item.name);
this.FileList.addItem({label:item.name, data:item});
}
EnableButtons();
//loadQueue(uploadQueue);// Laster Opp bildene
}
function DisableButtons(){
if(this.FileList.length==0){
ButtonUploadFiles.enabled = false;
ButtonRemoveElement.enabled = false;
ButtonEmtyList.enabled = false;
//this.PgBar.visible = false;
}
}
function EnableButtons(){
ButtonUploadFiles.enabled = true;
ButtonRemoveElement.enabled = true;
ButtonEmtyList.enabled = true;
}
function clickEmtyList(eventObj:MouseEvent):void{
this.FileList.removeAll();
DisableButtons();
}
function clickRemoveSelectedItems(eventObj:MouseEvent):void{
var numSelected:Number = FileList.selectedIndices.length;
for (var i:Number = 0; i < numSelected; i++) {
FileList.removeItemAt(FileList.selectedIndices);
}
DisableButtons();
}
function clickUploadFiles(eventObj:MouseEvent):void{
loadQueue();
//this.PgBar.visible = true;
}
function loadQueue():void{
if(FileList.length>0){
Debug.text = "Start";
var request:URLRequest = new URLRequest("/uploader.php");
var file:FileReference = FileReference(FileList.getItemAt(0).data);
file.addEventListener(Event.COMPLETE, completeHandler);
file.addEventListener(ProgressEvent.PROGRESS, progressHandler);
file.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
try
{
file.upload(request);
}
catch (error:Error)
{
Debug.text += "Unable to upload files.";
}
Debug.text +="Okei.";
}else{
DisableButtons();
Debug.text += "Nothing to upload.";
}
}
function completeHandler(event:Event):void{
var file:FileReference = FileReference(event.target);
file.removeEventListener(Event.COMPLETE, completeHandler);
file.removeEventListener(ProgressEvent.PROGRESS, progressHandler);
file.removeEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
FileList.removeItemAt(0);
Debug.text +=("-- Fil lastet opp --");
//this.PgBar.value = 0;
loadQueue();
}
function progressHandler(event:ProgressEvent):void {
var file:FileReference = FileReference(event.target);
//this.PgBar.minimum = 0;
//this.PgBar.maximum = event.bytesTotal;
//this.PgBar.value = event.bytesLoaded ;
Debug.text +=("\nprogressHandler: name = " + file.name + " bytesLoaded = " + event.bytesLoaded + " bytesTotal = " + event.bytesTotal);
}
function ioErrorHandler(event:IOErrorEvent):void {
Debug.text +=("\n\nioErrorHandler: " + event);
//this.PgBar.value = 0;
}