【问题标题】:AS3 Error 2038 on Windows only仅限 Windows 上的 AS3 错误 2038
【发布时间】:2012-10-02 17:08:40
【问题描述】:

希望有人可以帮助我!

我已经在 Flash 中编写了一个简单的在线 3d 编辑器 - 它即将用于选择的客户,但文件上传器有一点小故障,它刚刚抬起了它丑陋的脑袋。使用 FileReference 将媒体上传到 https 页面,它在 OSX 上就像它所构建的梦想一样工作,但在 Windows 上,它在每个浏览器上都返回错误 2038。有没有人遇到过这种情况?

非常感谢任何帮助!

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

【问题讨论】:

  • 我可以向你保证 FileReference 在 Windows 上工作。发布您使用的相关代码。
  • 我知道,我以前在Windows上用过,我只是用:(这是一个顺序上传多个文件的类)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);文件.上传(上传网址);这适用于 OSX,但在 Windows 上总是得到 IO_ERROR...
  • 您的上传脚本是否返回任何内容?成功上传后,回显“成功”之类的内容。我遇到的问题是,如果上传脚本(我使用 PHP)没有输出任何内容,它会在某些浏览器/机器上失败
  • 编辑您的答案以包含您创建 file 对象的代码
  • 是的,它丢弃了 XML 响应 200,奇怪的是这个问题仅限于 Windows,认为这可能是从系统上传文件的问题,但看起来是 xferring 的问题,驱使我精神!

标签: actionscript-3 flash upload filereference ioerror


【解决方案1】:

在尝试了几乎所有解决方案后,其他 Web 开发人员发现它可以正常工作,减去花哨的 url 名称,即引用 ourserver/thepage.php 而不是 ourserver/service。太疯狂了。

【讨论】:

    【解决方案2】:

    我今天遇到了这个问题,就我而言,我是跟踪源(url / nativePath)的长度和destin的长度;我发现destin url的长度最多为256个字符。

    为了解决这个问题,我被更改了目的地点(使用符号链接或网络驱动器)

    例子:

    // 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/";
    

    瞧,新名称减少了几个字符。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-09
      • 2018-08-19
      • 2015-11-30
      相关资源
      最近更新 更多