Wednesday, June 01, 2011

Sinatra Ajax File Upload

Valums script at http://valums.com/ajax-upload/ works like a charm in sinatra route you would require something like

  get :upload do
render "/test/upload", :layout => false
end
post :upload do
logger.debug params
newf = File.open("public/post.jpg", "wb")
newf.write(request.body.read)
'{success:true}'
end

0 comments:

Post a Comment