Instantly share code, notes, and snippets.

Embed
What would you like to do?
Uploading multiple files with ruby, uplodify and sinatra : http://www.gideondsouza.com/blog/uploading-multiple-images-with-ruby-and-sinatra/
require 'sinatra'
get '/' do
erb :form_multiple
end
post '/upload' do
#this method will get as ajax call for every file uploaded
@filename = params[:Filename]
file = params[:Filedata][:tempfile]
File.open("./public/#{@filename}", 'wb') do |f|
f.write(file.read)
end
#return filename as the response, the file we just wrote.
return @filename
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment