Flash 运行时无法在 IE8 中使用 PLupload 运行

发布于 2024-12-24 20:59:38 字数 3136 浏览 3 评论 0原文

中有简单的 javascript 函数,

var uploader = new plupload.Uploader({
         runtimes: 'html5,flash,silverlight',
         browse_button: 'pickfiles',
         container: 'uploader',
         max_file_size: '20mb',
         unique_names: true,
         multiple_queues: false,
         //drop_element: 'dropzone',
         url: '/Home/Upload',
         flash_swf_url: '../../../Scripts/upload/plupload.flash.swf',
         silverlight_xap_url: '../../../Scripts/upload/plupload.silverlight.xap',
         filters: [
               { title: "Image files", extensions: "jpg,gif,png" },
               { title: "Zip files", extensions: "zip" }
           ],
         chunk_size: '2mb',
         resize: { width: 320, height: 240, quality: 90 }
      });

      uploader.bind("Init", function (up, params) {
         $("#runtime").html("<div>Current runtime: " + params.runtime + "</div>");
      });

      $("#uploadfiles").bind("click", function (e) {
         uploader.start();
         e.preventDefault();
      });

      uploader.init();

      uploader.bind("FilesAdded", function (up, files) {
         $.each(files, function (i, file) {
            $('#runtime').append(
                '<div id="' + file.id + '">' +
                    file.name + ' (' + plupload.formatSize(file.size) + ') <b></b>' +
           '</div>');
         });
         up.refresh();
      });

      uploader.bind("UploaderProgress", function (up, file) {
         $("#" + file.id + " b").html(file.percent + "%");
      });

      uploader.bind("Error", function (up, file) {
         $('#runtime').append("<div>Error: " + err.code +
                ", Message: " + err.message +
                (err.file ? ", File: " + err.file.name : "") +
                "</div>");
         up.refresh();
      });

      uploader.bind("FileUploaded", function (up, file) {
         $("#" + file.id + " b").html("100%");
      });

我在 $(function() { ... }); 正文和 HTML 代码

<div class="container">
                  <div>Logo: </div>
                  <div style="clear"></div>
                  <div id="uploader">
                    <div id="runtime" class="right">
                        No runtime was found !
                    </div>
                    <div>
                        <a id="pickfiles" href="#">[Select files]</a>
                        <a id="uploadfiles" href="#">[Upload files]</a>
                    </div>
                  </div>
               </div>

错误如下图所示: 在此处输入图像描述

https://i.sstatic.net/G9TZX.jpg(查看完整尺寸)

我发现文件过滤器存在问题。我在 IE8 上运行 PLUpload.com 示例,它与 Flash 运行时配合良好。

在其他浏览器上,我的上传器运行良好。 另外,我已经为所有浏览器(IE8、FF9、Chrome 16)安装了最新版本的 Flash,但问题仍然存在于 IE8 中。

已解决的问题: 不要将 uploader 对象插入具有 visibility:hiddendisplay:none 属性的 div。

I have the simple javascript function inside $(function() { ... }); body

var uploader = new plupload.Uploader({
         runtimes: 'html5,flash,silverlight',
         browse_button: 'pickfiles',
         container: 'uploader',
         max_file_size: '20mb',
         unique_names: true,
         multiple_queues: false,
         //drop_element: 'dropzone',
         url: '/Home/Upload',
         flash_swf_url: '../../../Scripts/upload/plupload.flash.swf',
         silverlight_xap_url: '../../../Scripts/upload/plupload.silverlight.xap',
         filters: [
               { title: "Image files", extensions: "jpg,gif,png" },
               { title: "Zip files", extensions: "zip" }
           ],
         chunk_size: '2mb',
         resize: { width: 320, height: 240, quality: 90 }
      });

      uploader.bind("Init", function (up, params) {
         $("#runtime").html("<div>Current runtime: " + params.runtime + "</div>");
      });

      $("#uploadfiles").bind("click", function (e) {
         uploader.start();
         e.preventDefault();
      });

      uploader.init();

      uploader.bind("FilesAdded", function (up, files) {
         $.each(files, function (i, file) {
            $('#runtime').append(
                '<div id="' + file.id + '">' +
                    file.name + ' (' + plupload.formatSize(file.size) + ') <b></b>' +
           '</div>');
         });
         up.refresh();
      });

      uploader.bind("UploaderProgress", function (up, file) {
         $("#" + file.id + " b").html(file.percent + "%");
      });

      uploader.bind("Error", function (up, file) {
         $('#runtime').append("<div>Error: " + err.code +
                ", Message: " + err.message +
                (err.file ? ", File: " + err.file.name : "") +
                "</div>");
         up.refresh();
      });

      uploader.bind("FileUploaded", function (up, file) {
         $("#" + file.id + " b").html("100%");
      });

and HTML code

<div class="container">
                  <div>Logo: </div>
                  <div style="clear"></div>
                  <div id="uploader">
                    <div id="runtime" class="right">
                        No runtime was found !
                    </div>
                    <div>
                        <a id="pickfiles" href="#">[Select files]</a>
                        <a id="uploadfiles" href="#">[Upload files]</a>
                    </div>
                  </div>
               </div>

The error is shown in the following picture:
enter image description here

https://i.sstatic.net/G9TZX.jpg (to view full size)

I see there that is a problem with file filters. I run PLUpload.com examples on IE8 and it works fine with Flash runtime.

On other browsers, my uploader works perfectly.
Also, I have installed the latest version of Flash for ALL browsers (IE8,FF9,Chrome 16) but the problem insists in IE8.

ISSUE FIXED:
do not insert uploader object into div which has visibility:hidden or display:none property.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

夏夜暖风 2024-12-31 20:59:39

这也解决了问题:

#pickfiles{
    display:block;
}

或者这样:

$('#pickfiles').on("mouseover",function(){
                $(".plupload.flash").css({
                    left:$('#pickfiles').offset().left+'px',
                    top:$('#pickfiles').offset().top+'px'
                    });
                });

This solved the problem too:

#pickfiles{
    display:block;
}

or this:

$('#pickfiles').on("mouseover",function(){
                $(".plupload.flash").css({
                    left:$('#pickfiles').offset().left+'px',
                    top:$('#pickfiles').offset().top+'px'
                    });
                });
握住我的手 2024-12-31 20:59:39

在您的系统上安装 microsoft silverlight。这将解决问题,并且不要忘记向您的用户提供安装 silverlight 的消息。

Install microsoft silverlight on your system.That will solve the issue, and don't forget to give a message for your users to install silverligth.

青春如此纠结 2024-12-31 20:59:39

这个错误的解决方法是:

将“html4”添加到属性:“runtimes”

var uploader = new plupload.Uploader({
        runtimes : 'gears,html5,flash,silverlight,browserplus,**html4**',
        browse_button : 'pickfiles_<? echo  $tmpKey ?>',
        container : 'container_<? echo  $tmpKey ?>',
        max_file_size : '30mb',
        url : '/image/upload3',
        flash_swf_url : '/plupload/js/plupload.flash.swf',
        silverlight_xap_url : '/plupload/js/plupload.silverlight.xap',
        filters : [
            {title : "Image files", extensions : "jpg,gif,png,jpeg"},
            {title : "Zip files", extensions : "zip"}
        ],
        unique_names:false,
        multipart_params : {
            "tmpPath" : "<? echo $tmpPath ?>",
            "minWidth" : "<? if(isset($minWidth)) echo $minWidth; else echo 0; ?>",
            "minHeight" : "<? if(isset($minHeight)) echo $minHeight; else echo 0; ?>"
        }
    //  resize : {width : 390, height : 290, quality : 90}
    });

祝你好运!

This error solved by:

Add "html4" to properties: "runtimes"

var uploader = new plupload.Uploader({
        runtimes : 'gears,html5,flash,silverlight,browserplus,**html4**',
        browse_button : 'pickfiles_<? echo  $tmpKey ?>',
        container : 'container_<? echo  $tmpKey ?>',
        max_file_size : '30mb',
        url : '/image/upload3',
        flash_swf_url : '/plupload/js/plupload.flash.swf',
        silverlight_xap_url : '/plupload/js/plupload.silverlight.xap',
        filters : [
            {title : "Image files", extensions : "jpg,gif,png,jpeg"},
            {title : "Zip files", extensions : "zip"}
        ],
        unique_names:false,
        multipart_params : {
            "tmpPath" : "<? echo $tmpPath ?>",
            "minWidth" : "<? if(isset($minWidth)) echo $minWidth; else echo 0; ?>",
            "minHeight" : "<? if(isset($minHeight)) echo $minHeight; else echo 0; ?>"
        }
    //  resize : {width : 390, height : 290, quality : 90}
    });

Good luck for you!!!

潇烟暮雨 2024-12-31 20:59:38

对于与我有同样问题的每个人:

我有以下 HTML 代码

<div class="container" style="display:none">
                  <div>Logo: </div>
                  <div style="clear"></div>
                  <div id="uploader">
                    <div id="runtime" class="right">
                        No runtime was found !
                    </div>
                    <div>
                        <a id="pickfiles" href="#">[Select files]</a>
                        <a id="uploadfiles" href="#">[Upload files]</a>
                    </div>
                  </div>
</div>

container 被创建为对话框

$(function()
{
$(".container").dialog({modal:true, width:400});
});

我们知道 DIV 最初是隐藏的,因为 dispaly:none (当然,您可以将 autoOpen:false 设置为对话框对象中的新选项)并删除样式。

在 IE8 中(可能是早期和更高版本),如果 div 被隐藏,上传器就无法很好地实例化。 (返回上述错误)

在 Chrome 和 Firefox 中(我没有在 Opera 中测试此问题)工作正常。

因此,我的建议是避免隐藏块(即使您希望创建模式对话框)。

我从该 div 中删除了 display:none 样式和 dialog 对象,现在在 IE8 中工作得很好。

为什么 ?我不知道为什么在 IE 中,页面启动时没有创建对象的实例,但在 Firefox 和 Chrome 中,实例已正常创建。

For everyone who has same problem as me:

I had the following HTML code

<div class="container" style="display:none">
                  <div>Logo: </div>
                  <div style="clear"></div>
                  <div id="uploader">
                    <div id="runtime" class="right">
                        No runtime was found !
                    </div>
                    <div>
                        <a id="pickfiles" href="#">[Select files]</a>
                        <a id="uploadfiles" href="#">[Upload files]</a>
                    </div>
                  </div>
</div>

The class container was created as dialog

$(function()
{
$(".container").dialog({modal:true, width:400});
});

As we know that DIV is initial hidden because of dispaly:none (of course, you can set up autoOpen:false as a new option in dialog object) and remove the style.

In IE8 (probably in earlier and later version) the uploader cannot be good instantiated if the div is hidden. (Returns the above error)

In Chrome and Firefox (I don't test this issue in Opera) works fine.

So, my advice is to avoid hidden block (even if you wish to create modal dialog).

I removed the display:none style and dialog object from that div and now works very good in IE8.

Why ? I don't know why in IE, the instance of object is not created at startup of page, though in Firefox and Chrome, the instance was created normally.

影子的影子 2024-12-31 20:59:38

显示 div 后,执行以下操作:

uploader.refresh();

我在我的页面上进行了测试,成功了!

after the div is showing, do this:

uploader.refresh();

I have test on my page, worked!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文