Uploadify Rails 3.0 - 选择文件后没有任何反应 [英] Uploadify Rails 3.0 - Nothing happens after file is chosen

查看:44
本文介绍了Uploadify Rails 3.0 - 选择文件后没有任何反应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试让 uploadify 与 rails 3 一起工作,但收效甚微.我几乎阅读了所有有关此内容的内容,并尝试了几乎所有内容,但似乎没有任何效果.

I am trying to get uploadify to work with rails 3 but with little success. I have pretty much read everything there is to read about this, and tried pretty much everything, but nothing seems to work.

这是我的 javascript/jquery ..... 与表单字段.

Heres my javascript/jquery.....with the form field.

<script type="text/javascript">
        $(document).ready(function() {
            $('#video_upload').click(function(event){
                event.preventDefault();
          });

        $('#video_upload').uploadify({
                'uploader'          : '/javascripts/uploadify/uploadify.swf',
                'script'            : '/videos/create',
                'sizeLimit'       : '2000.bytes',
                'cancelImg'         : '/images/cancel.png',
                'multi'             : false,
                'scriptData': { 'format': 'json', 'authenticity_token': encodeURIComponent('<%= form_authenticity_token if protect_against_forgery? %>') }
            });


          $('#video_submit').click(function(event){
                event.preventDefault();
                    $('#video_upload').uploadifyUpload();
            });

        }); 
</script>
<input id="video_upload" width="120" type="file" height="30" name="video[upload]">

我有一个简单的videos_controller,它使用回形针处理文件数据(这适用于普通的html上传).当我选择一个文件时,一切正常 - 进度条出现等 - 但没有任何反应.控制台或日志中没有打印任何内容.我认为这是一个真实的事情,但已经尝试了这方面的一切,但仍然没有运气......非常令人沮丧.

And I have a simple videos_controller, which uses paperclip to handle file data (this works fine with normal html uploads). When I choose a file, everything works - the progress bar appears etc - but then nothing happens. There is nothing printed to the console or in the logs. I thought it was an authenticity thing, but have tried about everything on that front and still no luck... Very frustrating.

任何帮助都会很棒.

编辑 ========

EDIT ========

为了避免有一个按钮来启动上传,我认为这是原始情况,请在您的uploadify配置中使用 auto: true .虽然代表我的疏忽几乎打破了我的大脑.

To avoid having a button to initiate the upload, which I thought was the original case, use auto: true in your uploadify config. While an oversight on my behalf it almost broke my brain.

推荐答案

正如上面的评论中提到的,看起来他只是从他的示例中遗漏了一些东西

As mentioned in the comments above, looks like he just missed something from his sample

现在他的 jQuery 将为 video_submit 按钮注册一个点击事件并在点击后上传文件

Now his jQuery will register a click event for the video_submit button and upload the file Once clicked

这篇关于Uploadify Rails 3.0 - 选择文件后没有任何反应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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