Created
May 1, 2010 17:13
-
-
Save morganp/386495 to your computer and use it in GitHub Desktop.
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
# Sinatra method for handling file uploads | |
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment