Skip to content

Instantly share code, notes, and snippets.

@gideondsouza
Last active May 31, 2016 10:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gideondsouza/59f1d9ccb2551d0c06e8c47351a063f8 to your computer and use it in GitHub Desktop.
Save gideondsouza/59f1d9ccb2551d0c06e8c47351a063f8 to your computer and use it in GitHub Desktop.
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