Created
March 26, 2009 11:36
-
-
Save RSpace/86027 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% content_for :head do %> | |
<%= javascript_include_tag 'jquery.uploadify' %> | |
<% javascript_tag do %> | |
$(document).ready(function() { | |
$("#file_uploader").fileUpload({ | |
'uploader': '/flash/uploader.swf', | |
'script': '<%= url %>', | |
'scriptData': { 'format': 'json', 'authenticity_token': encodeURIComponent('<%= form_authenticity_token if protect_against_forgery? %>'), '<%= Rails.configuration.action_controller.session[:session_key]%>': '<%= u session.session_id %>' }, | |
'fileDataName': $('#file_uploader input:file')[0].name, // Extract correct name of upload field from form field | |
//'scriptAccess': 'always', // Incomment this, if for some reason it doesn't work | |
'multi': <%= allow_multiple_files %>, | |
'auto': true, | |
'fileDesc': '<%= dialog_file_description %> (<%= allowed_extensions.collect { |ext| "*.#{ext}" }.join(';') %>)', | |
'fileExt': '<%= allowed_extensions.collect { |ext| "*.#{ext}" }.join(';') %>', | |
'sizeLimit': <%= max_size %>, | |
'simUploadLimit': 1, | |
'buttonImg': '/images/button-fixed.png', | |
'width': 120, | |
'height': 24, | |
'cancelImg': '/images/cancel.png', | |
'onComplete': function(event, data) { $.getScript(location.href) }, // We assume that we can refresh the list by doing a js get on the current page | |
'displayData': 'speed' | |
}); | |
}); | |
<% end %> | |
<% end %> | |
<div id="file_uploader"> | |
<p><%= f.file_field :uploaded_data %></p> | |
<div class="submitbutton"><%= submit_tag "Upload" %></div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment