-->

如果不是file_dialog_complete_handler中调用SWFUpload的start

2019-09-22 03:12发布

我试图让SWFUpload的一个图像正常上传到我的服务器,与必须附带图像其他职位数据一起。 有一个表格填满数据,以便用户点击浏览按钮,并选择自己的图像文件后,图像不上传的时候了。 它被保存在队列中,直到用户点击发送按钮,然后我打电话mySwfUploadInstance.startUpload(),以便上传开始。

但它在功能swfupload.js的452线悲惨失败“callFlash”:

Uncaught Call to ReturnUploadStart failed

被抓住的异常之前抛出这个错误是:

Object #<HTMLObjectElement> has no method 'CallFunction'

在下面的功能:

SWFUpload.prototype.callFlash = function (functionName, argumentArray) {
    argumentArray = argumentArray || [];

    var movieElement = this.getMovieElement();
    var returnValue, returnString;

    // Flash's method if calling ExternalInterface methods (code adapted from MooTools).
    try {
        returnString = movieElement.CallFunction('<invoke name="' + functionName + '" returntype="javascript">' + __flash__argumentsToXML(argumentArray, 0) + '</invoke>');
        returnValue = eval(returnString);
    } catch (ex) {
        throw "Call to " + functionName + " failed";
    }

    // Unescape file post param values
    if (returnValue != undefined && typeof returnValue.post === "object") {
        returnValue = this.unescapeFilePostParams(returnValue);
    }

    return returnValue;
};

movieElement看起来就像是一个有效的flash对象。

如果我叫startUpload()我通过初始化的SWFUpload时file_dialog_complete_handler函数内我没有得到这个错误:

function ImageFileDialogComplete(numFilesSelected, numFilesQueued)
{
    try
    {
        this.startUpload();
    }
    catch (ex)
    {
        this.debug(ex);
    }
}

我真的需要能够推迟上传当用户完成表格,然后点击发送按钮。

任何想法有什么不对的SWFUpload当我打电话startUpload()从对话框完整的处理程序?

Answer 1:

看来这个问题是因为我躲在含通过设置显示Flash对象的DIV:它没有,右()调用之前startUpload。 我这样做是为了隐藏表单,并显示一个进度条,而不是一个div。

出于某种原因,闪存对象必须在屏幕上其他仍然可见它做会失败的所有呼叫。



文章来源: SWFUpload startUpload() fails if not called within the file_dialog_complete_handler