# Upload file via browser

**URL:** <https://www.ruby-forum.com/t/upload-file-via-browser/169504>\
**Category:** Ruby\
**Created:** [June 4, 2009, 4:55pm UTC](https://www.ruby-forum.com/t/upload-file-via-browser/169504 "2009-06-04T16:55:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [June 4, 2009, 4:55pm UTC](https://www.ruby-forum.com/t/upload-file-via-browser/169504/1 "2009-06-04T16:55:14Z")

</div>

I want to write a program to let people upload files to my computer  
via a browser (www.mydomain.tld/upload) - what do I need in order to  
write this code? Do I need to use RoR (I think RoR would be an  
overkill in this situation)?

Thanks.

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [June 4, 2009, 5:14pm UTC](https://www.ruby-forum.com/t/upload-file-via-browser/169504/2 "2009-06-04T17:14:37Z")

</div>

only for file uploading, the most efficient way would be with rack.Look  
around for file uploading middleware.

If you want just a bit more sugar, try sinatra.

2009/6/4 Chris H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [June 4, 2009, 5:31pm UTC](https://www.ruby-forum.com/t/upload-file-via-browser/169504/3 "2009-06-04T17:31:50Z")

</div>

For just an occasional file upload, even a CGI would be fine -  
especially if you have a web server already running with a cgi-bin  
directory.

Otherwise, if you want a standalone ruby process accepting uploads, I  
agree that sinatra would be the easiest way to get going.

get ‘/upload’ do  
… display a HTML page with a form (enctype=“multipart/form-post”)  
end

post ‘/upload’ do  
… parse the params, read the file, store it to disk  
end
