开发者

Uploadify Rails 3.0 - Nothing happens after file is chosen

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.

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]">

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.

Any help would be really great.

EDIT ========

To avoid having a button to initiate the upload, which I thought was the original case, use auto: true in your uploadify开发者_StackOverflow 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

<input id="video_submit" type="submit" value="Upload my Video!"/>

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜