Created
March 24, 2014 13:32
-
-
Save emad-elsaid/9740135 to your computer and use it in GitHub Desktop.
Uplaod files and images from you android to your desktop/laptop
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
#!/usr/bin/env ruby | |
# Author : Emad Elsaid (https://github.com/blazeeboy) | |
require 'sinatra' | |
set :port, 3000 | |
set :environment, :production | |
get '/' do | |
<<-EOT | |
<html><head> | |
</head><body style="padding:0px;margin:0px;"> | |
<form action="/upload" method="post" enctype="multipart/form-data" > | |
Choose files <input type="file" name="files[]" multiple> | |
<input type="submit" value="Upload" /> | |
</form> | |
</body></html> | |
EOT | |
end | |
post '/upload' do | |
params['files'].each do |f| | |
tempfile = f[:tempfile] | |
filename = f[:filename] | |
FileUtils.copy(tempfile.path, "./#{filename}") | |
end | |
redirect '/' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment