
Image Source: images.devshed.com
If you want your site visitor to upload a certain file on your server, Rails make it an easy task to undertake the requirement. We will use the new application of Ruby on Rails called upload. We can create the basic structure of the application. And we will need simple Rails commands. Start off with C:\ruby>rails upload, then decide if you’re going to save the uploaded file. Create the directory and then check permissions. Next thing to do is to create the controller and models. You can call helper function content_type to know media type of the uploaded file. Next is to open a file in write mode so we will be using open helper function which is provided by File object. The render function is to be used to redirect to view files and to display message. The last is to create a view file uploadfile.rhtml. Set the parameter to True so that the action will pass on the data properly.







