Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# Sinatra method for handling file uploads
# based on
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>
post '/upload' do
FileUtils.mkdir_p('./Uploads/')[:uploaded_data][:tempfile].path, "./Uploads/#{params[:uploaded_data][:filename]}")
erb 'Upload Complete'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment