Ruby on rails Firefox文件上载窗口未出现

Ruby on rails Firefox文件上载窗口未出现,ruby-on-rails,firefox,file-upload,Ruby On Rails,Firefox,File Upload,在我的Rails应用程序中,我的表单中有一个文件字段输入,允许用户上传文件。当用户上传文件时,我使用ajax自动提交表单。它在Safari和Chrome中运行良好,但在Firefox中,当我点击“上传视频”按钮时,文件上传窗口(用户可以在其中选择要上传的文件)永远不会出现,表单会自动提交,而不包含任何文件 在Firefox中上传文件有什么特别的功能吗 这是我的密码: <div id="uploadVideoWrapper" title="Add Video"> &

在我的Rails应用程序中,我的表单中有一个文件字段输入,允许用户上传文件。当用户上传文件时,我使用ajax自动提交表单。它在Safari和Chrome中运行良好,但在Firefox中,当我点击“上传视频”按钮时,文件上传窗口(用户可以在其中选择要上传的文件)永远不会出现,表单会自动提交,而不包含任何文件

在Firefox中上传文件有什么特别的功能吗

这是我的密码:

    <div id="uploadVideoWrapper" title="Add Video">
      <button class="btn btn-primary uploadVideoButton">
        Upload Video
      </button>
      <input class="video_file_upload_field" id="video_video_path" name="video[video_path]" onchange="return validateFileExtension(this)" type="file">
    </div>

上传视频
在用户上传文件(video.js.coffee.erb)后,使用my Ajax提交表单:

jQuery->
$('#VideoEmbeddeModal')。文件上载
数据类型:“脚本”
加:(e,数据)->
console.log('上传的视频')
类型=/(\.\/)(mov | mp4 | avi)$/i
文件=数据。文件[0]
大小=文件大小/(10e5)
大小限制=25#文件大小限制为50MB
if(types.test(file.type)| types.test(file.name))&(size');
$('.placeholder').hide();
data.context=$(tmpl(“视频上传”,文件))
#$('#videoUploadProgress').append(data.context)
数据提交()
否则如果(尺寸>尺寸限制)
警报(“您的视频大于50 MB,无法上载。请上载到Youtube或Vimeo,并嵌入您的视频。”)
其他的
警报(#{file.name}不是受支持的视频格式)
进展:(e,数据)->
if data.context
进度=parseInt(data.loaded/data.total*100,10)
#data.context.find('.bar').css('width',progress+'%'))
如果进度==100
设置超时(->
$('.embedModal').modal('hide');
), 2000
$('.placeholder').show();
document.getElementById(“图像”).scrollTop=document.getElementById(“图像”).scrollHeight

结果是,输入与我的按钮偏移,因此用户在单击按钮时没有实际单击输入字段。一个简单的解决方案,但它花了一些时间来解决

jQuery ->
  $('#videoEmbedModal').fileupload
    dataType: "script"
    add: (e, data) ->
        console.log('uploaded video')
        types = /(\.|\/)(mov|mp4|avi)$/i
        file = data.files[0]
        size = file.size/(10e5)
        size_limit = 25 # file size limit is 50 mb
        if (types.test(file.type) || types.test(file.name)) && (size < size_limit)
            $('#video_submit').html('Saving...')
            $('#videoFileName').html(file.name)
            $('.uploadVideoButton').attr('disabled', true)
            $('.video_file_upload_field').attr('disabled', true)
            $('.loadingIcon').show()
            $('#images').append('<div class="placeholder video" style="background-image: none">uploading video...<br><%=image_tag("icons/loading.gif")%></div>');
            $('.placeholder').hide();
            data.context = $(tmpl("video-upload", file))
            # $('#videoUploadProgress').append(data.context)
            data.submit()
        else if (size > size_limit)
            alert("Your video is larger than 50 MB and cannot be uploaded.  Please upload to Youtube or Vimeo and embed your video instead.")
        else
            alert("#{file.name} is not a supported video format")
    progress: (e, data) ->
        if data.context
            progress = parseInt(data.loaded / data.total * 100, 10)            
            # data.context.find('.bar').css('width', progress + '%')
            if progress == 100
                setTimeout ( -> 
                    $('.embedModal').modal('hide');
                    ), 2000
                $('.placeholder').show();
                document.getElementById("images").scrollTop = document.getElementById("images").scrollHeight