Skip to main content
Participant
January 23, 2010
Question

Is there a problem with FileReference and different browser plugins?

  • January 23, 2010
  • 1 reply
  • 607 views

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;
}

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
January 23, 2010

are you using the html file published by flash?

JonVollarAuthor
Participant
January 23, 2010

Yes, Im using it...... Is there a better way to include it in html?


This is what I'm using now( replaced alle the functions with ... so it is alot shorter), but it is what Flash genereates on publising...


<!--
//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2008 Adobe Systems Incorporated.  All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
function ControlVersion()
{
...
}
// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
...
}
// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
...
}
function AC_AddExtension(src, ext)
{
  ...
}
function AC_Generateobj(objAttrs, params, embedAttrs)
{
  ...
}
function AC_FL_RunContent(){
  ...
}
function AC_SW_RunContent(){
  ...
}
function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  ...
}
// -->
</script>

...

<script language="JavaScript" type="text/javascript">
AC_FL_RunContent(
  'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
  'width', '350',
  'height', '400',
  'src', 'uploader',
  'quality', 'high',
  'pluginspage', 'http://www.adobe.com/go/getflashplayer',
  'align', 'middle',
  'play', 'true',
  'loop', 'true',
  'scale', 'showall',
  'wmode', 'window',
  'devicefont', 'false',
  'id', 'uploader',
  'bgcolor', '#ffffff',
  'name', 'uploader',
  'menu', 'true',
  'allowFullScreen', 'false',
  'allowScriptAccess','sameDomain',
  'movie', 'uploader',
  'salign', ''
  ); //end AC code
</script>
<noscript>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="350" height="400" id="uploader" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="false" />
<param name="movie" value="uploader.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /> <embed src="uploader.swf" quality="high" bgcolor="#ffffff" width="350" height="400" name="uploader" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" />
</object>
</noscript>

kglad
Community Expert
Community Expert
January 23, 2010

using the html published by flash is the most reliable way to embed a swf so, don't change that html code.

what's the url to your embedding html?