如果未在file_dialog_complete_handler中调用,SWFUpload startUpload()将失败 [英] SWFUpload startUpload() fails if not called within the file_dialog_complete_handler

查看:436
本文介绍了如果未在file_dialog_complete_handler中调用,SWFUpload startUpload()将失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试让SWFUpload正确地将图像上传到我的服务器,以及图像必须附带的其他帖子数据。有一个表单可以填充数据,因此在用户单击浏览按钮并选择其图像文件后,图像不会立即上传。它一直保留在队列中,直到用户点击发送按钮,然后我调用mySwfUploadInstance.startUpload()以便上传开始。

I am trying to get SWFUpload to properly upload an image to my server, along with other post data that must come with the image. There is a form to fill up the data so after the user clicks the browse button and selects his image file, the image is not uploaded right away. It is kept in the queue until the user clicks a send button, I then call mySwfUploadInstance.startUpload() so that the upload starts.

但它在第452行失败了函数'callFlash'中的swfupload.js:

But it fails miserably at line 452 of swfupload.js in the function 'callFlash':

Uncaught Call to ReturnUploadStart失败

抛出此错误之前捕获的异常如下:

The exception being caught before throwing this error is the following:

Object#< HTMLObjectElement>在以下函数中没有方法'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对象。

movieElement looks like being a valid flash object.

如果我在初始化SWFUpload时传递给file_dialog_complete_handler的函数中调用startUpload(),则不会出现该错误:

I do not get that error if I call startUpload() inside the function I pass to file_dialog_complete_handler when initializing SWFUpload:

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

我真的需要能够推迟上传到当用户完成表单并单击发送按钮时。

I really need to be able to postpone the upload to when the user completes the form and click the send button.

当我从对话框完成处理程序中调用startUpload()时,知道SWFUPload有什么问题吗?

Any idea what is wrong with SWFUPload when I call startUpload() out of the dialog complete handler?

推荐答案

似乎问题是因为我在调用startUpload之前就通过设置display:none来隐藏包含flash对象的div )。我这样做是为了隐藏表单并显示带有进度条的div。

It seems the problem was because I was hiding the div containing the flash object by setting display:none on it, right before calling startUpload(). I was doing this to hide the form and show a div with a progress bar instead.

由于某种原因,flash对象必须在屏幕上保持可见,否则所有调用它会失败。

For some reason the flash object must remain visible on screen else all calls made to it would fail.

这篇关于如果未在file_dialog_complete_handler中调用,SWFUpload startUpload()将失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆