problem in file uploading

Nadeesha Meththananda
2007-11-14T07:45:29Z

i wote a code to do file uploading with the hep given in documents in
the net.
but i came across some problems.

in the View section the form that was wrote in th normal HTML was
working 100% perfect and it uplodes the files also.

but when i edited that in the rails way (u can see the coding in the
second form tag), when i goes to upload the file it give a error as this

" You have a nil object when you didn''t expect it!
The error occurred while evaluating nil.read"


so if any body know where i have gone wrong ?????????


######### wrote in the controller page #######################33

   def create

    f = File.new("./uploads/data.doc", "wb");
    f.write (@params["upload_file"].read);
    f.close;

    render_action ''success''

  end


#################### wrote in the view ###################


<form action="create" method="post"
enctype="multipart/form-data">
<input type="file" name="upload_file"
/>
<input type="submit" name="Save"
value="Up load now"/>








<% form_for :form_file, :url => { :action => "create" },
:html => {
:multipart => true } do |g| %>
<%= g.file_field :upload_file %>
<%= submit_tag :Up_load_now %>
<% end %>