Skip to content

Instantly share code, notes, and snippets.

Created April 25, 2011 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/940960 to your computer and use it in GitHub Desktop.
Save anonymous/940960 to your computer and use it in GitHub Desktop.
uploadify file content
<%= debug @parent %>
<%= form_for [parent, upload], :html => { :multipart => true } do |f| %>
<div class="field">
<%= f.label :document %><br />
<%= f.file_field :document %>
</div>
<div class="actions">
<%= f.submit "Upload"%>
</div>
<%end%>
<%= render :partial => "uploads/uploadify" %>
<script type="text/javascript" >
<%- session_key = Rails.application.config.session_options[:key] -%>
$(document).ready(function() {
$('#upload_document').click(function(event){
event.preventDefault();
});
$('#upload-document').uploadify({
uploader : '/uploadify/uploadify.swf',
cancelImg : '/uploadify/cancel.png',
auto : true,
multi : true,
script : '/uploads/',
onComplete : function(event, queueID, fileObj, response, data) {
var dat = eval('(' + response + ')');
$.getScript(dat.upload);},
scriptData : {
'_http_accept': 'application/javascript',
'format' : 'json',
'_method': 'post',
"<%= key = Rails.application.config.session_options[:key] %>" : "<%= u cookies[key] %>",
"<%= request_forgery_protection_token %>" : "<%= u form_authenticity_token %>",
}
});
$('#upload_submit').click(function(event){
event.preventDefault();
$('#upload_document').uploadifyUpload();
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment