Last active
May 31, 2016 10:22
-
-
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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