Skip to content

Instantly share code, notes, and snippets.

@aq1018
Created April 19, 2010 07:13
Show Gist options
  • Save aq1018/370812 to your computer and use it in GitHub Desktop.
Save aq1018/370812 to your computer and use it in GitHub Desktop.
SWFUpload session cookie
def post_params_json
post_params = {}
post_params['authenticity_token'] = CGI::escape(form_authenticity_token)
post_params[session_key.to_s] = CGI::escape(cookies[session_key])
post_params.to_json
end
ActionController::Base.session = {
:key => '_your_session',
:secret => 'your key'
}
ActionController::Dispatcher.middleware.use FlashSessionCookieMiddleware, ActionController::Base.session_options[:key]
$(function(){
$(".swfuploader").swfuploader({
upload_url : "/images",
set : "MultiFile",
file_post_name : "image[attachment]",
post_param : <%= post_params_json %>
upload_success_handler : function(file, serverData, response){
var data = eval("("+ serverData + ")");
$(data.partial).hide().prependTo($(".images")).fadeIn();
}
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment