Sinatra File Upload
A simple Sinatra web app to upload a single file. Also available as a gist, based on http://pastie.caboo.se/134681
require 'rubygems'
require 'sinatra'
get '/upload' do
erb '<form action="upload" method="post" enctype="multipart/form-data" accept-charset="utf-8">
<input type="file" name="uploaded_data" id="uploaded_data">
<p><input type="submit" value="Continue"></p>
</form>'
end
post '/upload' do
FileUtils.mkdir_p('./Uploads/')
FileUtils.mv(params[:uploaded_data][:tempfile].path, "./Uploads/#{params[:uploaded_data][:filename]}")
erb 'Upload Complete'
end
Programming
Sinatra
]