与prettyPhoto一起使用uploadify:未捕获的异常:调用StartUpload失败 [英] uploadify with prettyPhoto : uncaught exception: Call to StartUpload failed

查看:95
本文介绍了与prettyPhoto一起使用uploadify:未捕获的异常:调用StartUpload失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们一直在使用 uploadify 上传图片和 dropbox 所使用的一样,但是如果与prettyPhoto一起使用,它会发出尖叫. >

以下是将uploadify与prettyPhoto一起使用的示例HTML.

<!DOCTYPE html>
<html>
<head>
    <title>My Uploadify Implementation</title>
    <link rel="stylesheet" type="text/css" href="uploadify.css">
    <link rel="stylesheet" type="text/css" href="prettyPhoto.css" />
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="jquery.uploadify-3.1.min.js"></script>
    <script src="jquery.prettyPhoto.js" type="text/javascript"></script>

    <script type="text/javascript">
    $(function() {
        $('#file_upload').uploadify({
            'swf'      : 'uploadify.swf',
            'uploader' : 'uploadify.php'
            // Your options here
        });

        $('#closeme').live('click', function() {
            $.prettyPhoto.close();
            return false;
        });

        $("a[rel^='prettyPhoto']").prettyPhoto();

    });
    </script>
</head>
<body>
<a href="#inline-1" rel="prettyPhoto" >popop</a>
    <div id="inline-1" style="display:none;">
        <p>This is inline content opened in prettyPhoto.</p>
        <input type="file" name="file_upload" id="file_upload" />
    </div>
</body>
</html>

在这里,您将看到指向弹出窗口的链接,单击该链接会在灯箱上显示上载控件.然后,您从磁盘中选择图像以上传到服务器.选择图像后,我面临两个问题:

1)在FF和Crome上出现Error: uncaught exception: Call to StartUpload failed javascript错误

2)所选图像未在灯箱的uploadify控件上列出.如果您关闭了该pupup,然后再次单击弹出链接,则会显示文件列表.

如果我删除$("a[rel^='prettyPhoto']").prettyPhoto();行,

Uploadify效果很好.

您是否知道如何解决?

如果有人建议使用其他插件来实现此类保管箱样式的上传器,我也将不胜感激.

谢谢,阿米特·帕特尔(Amit Patel)

解决方案

您将要在灯箱打开后而不是在页面加载时初始化uploadify.原因是因为如果元素被隐藏,Flash将不会加载.

我查看了prettyPhoto api,找不到在灯箱打开完毕后调用的任何事件,但这就是您需要做的.

We have been using uploadify for image upload and prettyPhoto for displaying images on lightbox in our Rails application. Both works well if used separately. Now we want to display uploadify control on lightbox just like dropbox uses but it start screaming if used with prettyPhoto.

Here is sample html using uploadify with prettyPhoto.

<!DOCTYPE html>
<html>
<head>
    <title>My Uploadify Implementation</title>
    <link rel="stylesheet" type="text/css" href="uploadify.css">
    <link rel="stylesheet" type="text/css" href="prettyPhoto.css" />
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="jquery.uploadify-3.1.min.js"></script>
    <script src="jquery.prettyPhoto.js" type="text/javascript"></script>

    <script type="text/javascript">
    $(function() {
        $('#file_upload').uploadify({
            'swf'      : 'uploadify.swf',
            'uploader' : 'uploadify.php'
            // Your options here
        });

        $('#closeme').live('click', function() {
            $.prettyPhoto.close();
            return false;
        });

        $("a[rel^='prettyPhoto']").prettyPhoto();

    });
    </script>
</head>
<body>
<a href="#inline-1" rel="prettyPhoto" >popop</a>
    <div id="inline-1" style="display:none;">
        <p>This is inline content opened in prettyPhoto.</p>
        <input type="file" name="file_upload" id="file_upload" />
    </div>
</body>
</html>

Here you will see link to popup and by clicking on the link it shows uploadify control on lightbox. Then you chooses images from the disk to upload to server. After choosing images I face two issues:

1) Getting Error: uncaught exception: Call to StartUpload failed javascript error on FF and Crome

2) The selected images are not getting listed on uploadify control on lightbox. If you close the pupup and again click on popup link it shows list of files.

Uploadify works fine if I remove $("a[rel^='prettyPhoto']").prettyPhoto(); line.

Do you have any idea how it can be fixed?

Also I would appreciate if someone suggest other plugins to achieve such dropbox style uploaders.

Thanks, Amit Patel

解决方案

You'll want to initialize uploadify after the lightbox is opened and not on page load. The reason for this is because Flash will not load if the element is hidden.

I looked at the prettyPhoto api and couldn't find any event that is called after the lightbox has finished opening, but that's what you'll need to do.

这篇关于与prettyPhoto一起使用uploadify:未捕获的异常:调用StartUpload失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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