Hey Tony,

You just need

  name =  upload['uploads'].original_filename

instead of

  name =  upload['uploads']

/Lasse

2010/3/26 Tony Augustine <[email protected]>

> i tried a method   to implementa file uploader  by  using amethod  below
>
> this is ma  controlller   method   to upload
>
> def save_imports
>    Contactslist.save(params[:list])
>    render :text => "File uploaded successfully"
>
>
> this is ma view  file
>
>
> .remote
>  - form_for(@list, :url=> save_imports_list_path(@list, :format =>
> "js"), :html => { :multipart => true, :target => "uploading", :onsubmit
> => "$('list_submit).disabled = true" }) do |f|
>    = link_to_close edit_list_path(@list)
>    .section
>      %small
>        #{t :add_contacts_from_file}
>      %table{ :width => 500, :cellpadding => 0, :cellspacing => 0 }
>        %tr
>          %td{ :valign => :top }
>          .label.top.req #{t :upload_new}:
>          =f.file_field  :uploads, :style => "width:240px"
>
>    .buttonbar
>      = f.submit "#{t:save_contacts}", :onclick => "this.disabled =
> true"
>      #{t :or}
>      = link_to_cancel edit_list_path(@list)
>
> i created   amodel  contact list and   nclude  amethod  as given  below
>
>
> class Contactslist < ActiveRecord::Base
> def self.save(upload)
>    name =  upload['uploads']
>    puts name
>    directory = "public/avatars"
>    # create the file path
>    path = File.join(directory, name)
>    # write the file
>    File.open(path, "wb") { |f| f.write(upload['uploads'].read) }
>  end
> end
> when i tried   to upload a file its  showing  errors  as
>
>
>
>  TypeError in ListsController#save_imports
>
> can't convert Tempfile into String
>
>
> can  anyone  help.is there any  fault in this  method?actually i  wanted
> toupload this  files into a table callled contactslists or  to move  to
> a  folder in  my application  pls  provide  help
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<rubyonrails-talk%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to