Skip to content

Instantly share code, notes, and snippets.

@mtgto
Created January 6, 2017 07:26
Show Gist options
  • Save mtgto/e7523f0cba6afa6406426c691b353b5e to your computer and use it in GitHub Desktop.
Save mtgto/e7523f0cba6afa6406426c691b353b5e to your computer and use it in GitHub Desktop.
Idiot simple http file uploader written by ruby. It requires sinatra.
# WARNING: This script has an enormous vulnerability!!!!!!
require 'sinatra'
get '/' do
erb <<"HTML"
<form action="upload" method="POST" enctype="multipart/form-data">
<input type="file" name="file" />
<input type="submit" value="Upload" />
</form>
HTML
end
post '/upload' do
filename = params[:file][:filename]
file = params[:file][:tempfile]
File.open(filename, 'wb') do |f|
f.write(file.read)
end
erb <<"HTML"
OK
HTML
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment