0

hope someone can help me with this!

I've written a simple online 3d editor in Flash - it's about to go out to a selection of clients but the file uploader has a bit of a glitch which has only just reared its ugly head. Using FileReference to upload media to https page, it works like a dream on OSX which is what it was built on, but on Windows it's returning Error 2038 on every browser. Has anyone encountered this before?

Any help much appreciated!

public class CustomFileReferenceList extends FileReferenceList {

    private var uploadURL:URLRequest;
    private var pendingFiles:Array;

    public static var length:int = 0;
    public static var arrLen:int = 0;

    public function CustomFileReferenceList() {
        uploadURL = new URLRequest();
        uploadURL.url = "https://___";
        var rqd:URLVariables = new URLVariables();
        uploadURL.method = URLRequestMethod.POST;
        rqd.sessionId = Main.sessionId;
        uploadURL.data = rqd;
        initializeListListeners();
    }

    private function initializeListListeners():void {
        addEventListener(Event.SELECT, selectHandler);
        addEventListener(Event.CANCEL, cancelHandler);
    }

    private function doOnComplete():void {
        //var event:Event = new Event(Uploader.LIST_COMPLETE);
        //dispatchEvent(event);
enter code here
    }

    private function addPendingFile(file:FileReference):void {
        pendingFiles.push(file);
        file.addEventListener(Event.OPEN, openHandler,false,0,true);
        file.addEventListener(Event.COMPLETE, completeHandler,false,0,true);
        file.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler,false,0,true);
        file.addEventListener(ProgressEvent.PROGRESS, progressHandler,false,0,true);
        file.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler,false,0,true);
        file.upload(uploadURL);
    }

    private function removePendingFile(file:FileReference):void {
        for (var i:uint; i < pendingFiles.length; i++) {
            if (pendingFiles[i].name == file.name) {
                pendingFiles.splice(i, 1);
                if (pendingFiles.length == 0) {
                    doOnComplete();
                }
                return;
            }
        }
    }

    private function selectHandler(event:Event):void {


        arrLen = length = fileList.length;
        pendingFiles = new Array();
        var file:FileReference;
        for (var i:uint = 0; i < fileList.length; i++) {
            file = FileReference(fileList[i]);
            addPendingFile(file);
        }
    }

    private function cancelHandler(event:Event):void {
        //var file:FileReference = FileReference(event.target);
    }

    private function openHandler(event:Event):void {
        var file:FileReference = FileReference(event.target);
    }

    private function progressHandler(event:ProgressEvent):void {
        var file:FileReference = FileReference(event.target);
    }

    private function completeHandler(event:Event):void {
        var file:FileReference = FileReference(event.target);
        length--;
        removePendingFile(file);
    }

    private function httpErrorHandler(event:Event):void {
        var file:FileReference = FileReference(event.target);
    }

    private function ioErrorHandler(event:Event):void {
        var file:FileReference = FileReference(event.target);
    }

    private function securityErrorHandler(event:Event):void {
        var file:FileReference = FileReference(event.target);
    }
}
MickMalone1983
  • 1,054
  • 8
  • 17
  • I can promise you FileReference works on windows. Post the relevant code your using. – BadFeelingAboutThis Oct 02 '12 at 17:15
  • I know, I've used it before on Windows, I'm just using: (This is a class to upload multiple files sequentially) pendingFiles.push(file); file.addEventListener(Event.OPEN, openHandler,false,0,true); file.addEventListener(Event.COMPLETE, completeHandler,false,0,true); file.addEventListener(IOErrorEvent.IO_ERROR,ioErrorHandler,false,0,true); file.addEventListener(ProgressEvent.PROGRESS,progressHandler,false,0,true); file.addEventListener(SecurityErrorEvent.SECURITY_ERROR,securityErrorHandler,false,0,true); file.upload(uploadURL); This works on OSX but always gets IO_ERROR on windows... – MickMalone1983 Oct 02 '12 at 17:17
  • does your upload script return anything? After a successful upload, echo something out like "success". I've had issues where if the upload script (I use PHP) didn't output anything, it would fail on certain browsers/machines – Ronnie Oct 02 '12 at 17:21
  • Edit your answer to include code where you create the `file` object – BadFeelingAboutThis Oct 02 '12 at 17:23
  • Yeah it chucks out XML response 200, strange that this issue is confined to Windows, figured it might be a problem with uploading the file from the system but looks to be a problem with xferring it, driving me mental! – MickMalone1983 Oct 02 '12 at 17:24
  • @LondonDrugs_MediaServices for (var i:uint = 0; i < fileList.length; i++) { file = FileReference(fileList[i]); addPendingFile(file); } – MickMalone1983 Oct 02 '12 at 17:25
  • Can you please post your upload script? You can hide any information, like domains if you like – Ronnie Oct 02 '12 at 17:26
  • Added to main question, thanks a million for this – MickMalone1983 Oct 02 '12 at 17:29
  • Sorry, I meant your server side script, not the AS3. Although both help us help you – Ronnie Oct 02 '12 at 17:30
  • I didn't write it and I don't currently have access to it, I can get hold but not at the moment(!) – MickMalone1983 Oct 02 '12 at 17:31
  • Hmm ok. Well, I think the server side upload script (not the as3 script) should output something on a successful upload. For me, Macs were having an issue that if the server side script didn't output anything, it would throw an error. Also, googling around, I found a person with the same issue you are having where it doesn't work on windows, but it works on mac: http://www.kirupa.com/forum/showthread.php?268410-file-upload-returns-ioError-2038 --Looks like adding an htaccess with `secfiltering` options fixed it – Ronnie Oct 02 '12 at 17:34
  • I'll give that a try tomorrow - you are a star mate, thanks so much – MickMalone1983 Oct 02 '12 at 17:35
  • yeah post back what you come up with..I am curious – Ronnie Oct 02 '12 at 17:47
  • It might have something to do with different endian values on Mac and Windows, IIRC MacOS has big endian everywhere, while Windows has little endian. So, when you upload a file from some variable, convert it into a ByteArray first, then check what endian works, and if different, change it to that endian settings with that ByteArray, and only then invoke upload. – Vesper Oct 02 '12 at 18:23
  • @Vesper it does look like you're right about that, was about to try when the solution came out of nowhere! – MickMalone1983 Oct 03 '12 at 13:16

2 Answers2

0

After trying just about every solution, the other web dev found it worked ok minus fancy url names i.e referencing ourserver/thepage.php instead of ourserver/service. Absolutely crazy.

MickMalone1983
  • 1,054
  • 8
  • 17
0

I have today this issue, in my case, I was be trace of the length of the source (url/nativePath) and the length of destin; I was found that the length of the destin url is up to 256 characters.

To solve this, I was be changed the destin point (with simbolic link or network drive)

Example:

// MAC remote path
var mSt:String  = "file:////MacBook-Pro-de-Jaime.local/Seagate/netShared/transport-machines/SoftDepot/";

// Windows Remote Drive (\\MacBook-Pro-...\transport-machines)
// Remote MAC as Windows Drive N
var mSt:String  = "file:///N:/SoftDepot/";

Voila, the new name reduces several characers.

J. A. Mendez
  • 67
  • 1
  • 5