我们一直在使用uploadify进行图像上传,而使用prettyPhoto在我们的Rails应用程序中在灯箱上显示图像。如果单独使用,两者都能很好地工作。现在我们想在灯箱上显示上传控件,就像 dropbox 使用一样,但如果与 prettyPhoto 一起使用,它会开始尖叫。
这是使用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)所选图像未在灯箱上的上传控件中列出。如果您关闭 pupup 并再次单击弹出链接,它会显示文件列表。
如果我删除$("a[rel^='prettyPhoto']").prettyPhoto();
行,上传工作正常。
您知道如何修复它吗?
如果有人建议其他插件来实现这种 Dropbox 风格的上传器,我将不胜感激。
谢谢,阿米特·帕特尔
灯箱打开后初始化上传,而不是在页面加载时初始化上传。 这样做的原因是,如果元素被隐藏,Flash 将不会加载。
我查看了漂亮的照片 api,找不到灯箱完成打开后调用的任何事件,但这就是您需要做的。