Skip to content

Instantly share code, notes, and snippets.

@burningTyger burningTyger/app.rb forked from lchanmann/app.rb
Created Jan 28, 2011

Embed
What would you like to do?
require 'rubygems'
require 'haml'
require 'sinatra'
require 'sinatra/flash'
require 'file_uploader'
enable :sessions
get '/' do
haml :index
end
post '/upload' do
FileUploader.create.save(params[:file]) do |path|
flash[:upload] = "#{path} is saved."
end
redirect '/'
end
__END__
@@ layout
%html
%head
%title File Uploader
%body
= yield
@@ index
%h1 File Uploader
- if flash[:upload]
%div{:style => 'color:green'}= flash[:upload]
%form{:action => '/upload', :method => 'post', :enctype => 'multipart/form-data'}
%label{:for => 'file'} Select file:
%input{:type => 'file', :id => 'file', :name => 'file'}
%input{:type => 'submit', :value => 'Upload'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.