Created
June 4, 2016 15:49
-
-
Save mgamba/1a263f3344207f0a1f482ae33817df16 to your computer and use it in GitHub Desktop.
file uploader because i'm too lazy to figure out how to make my phone talk to my computer
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
| require 'sinatra' | |
| require 'base64' | |
| set :environment, :production | |
| get '/' do | |
| html = ' | |
| <form action="run" method="POST" enctype="multipart/form-data"> | |
| <input type="file" name="file" accept="image/*" capture="camera"> | |
| <input type="submit" value="Upload image"> | |
| </form> | |
| ' | |
| end | |
| post '/run' do | |
| filename = params[:file][:filename] | |
| file = params[:file][:tempfile] | |
| File.open(filename, 'wb') do |f| | |
| f.write(file.read) | |
| end | |
| redirect to('/') | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment