Created
January 6, 2017 07:26
-
-
Save mtgto/e7523f0cba6afa6406426c691b353b5e to your computer and use it in GitHub Desktop.
Idiot simple http file uploader written by ruby. It requires sinatra.
This file contains hidden or 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
# 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