# Upload file and insert on a database

**URL:** <https://www.ruby-forum.com/t/upload-file-and-insert-on-a-database/169918>\
**Category:** Rails\
**Created:** [June 10, 2009, 8:30am UTC](https://www.ruby-forum.com/t/upload-file-and-insert-on-a-database/169918 "2009-06-10T08:30:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bakkhoz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d6d6ee/32.png) [@bakkhoz](https://www.ruby-forum.com/u/bakkhoz)\
**Post date:** [June 10, 2009, 8:30am UTC](https://www.ruby-forum.com/t/upload-file-and-insert-on-a-database/169918/1 "2009-06-10T08:30:59Z")

</div>

Hi

I miss something I don’t understand what?

i have form:

ho calls

```
def contacts_mailer
    mail = Notifier.create_contact_request(params[:contact])
    Notifier.deliver(mail)
    @contact = Contact.new
    @contact.file_file_name=params[:contact][:file].original_filename
    @contact.file_content_type=params[:contact][:file].content_type
    @contact.file=params[:contact][:file].read

    @contact.save
    redirect_to :action => 'contact'
    #render :file => "#{RAILS_ROOT}/public/thx1.html"
end

```

@contact.file is a BLOB but I am not finding the file it don’t get  
errors only a 0 byte file

create\_contact\_request(params[:contact])

where I use the same funcion Works

class Notifier \< ActionMailer::Base  
def contact\_request(recipient)  
recipients “”  
from recipient[:email]  
subject "Contact Request from “+recipient[:name]+”,  
"+recipient[:company]  
@body[“name”] = recipient[:name]  
@body[“company”] = recipient[:company]  
@body[“address”] = recipient[:address]  
@body[“phone”] = recipient[:phone]  
@body[“email”] = recipient[:email]  
@body[“notes”] = recipient[:notes]  
@body[“file”] = recipient[:file].original\_filename  
part :content\_type =\> “text/html”, :body =\>  
render\_message(“contact\_request”, @body)  
attachment :content\_type =\> recipient[:file].content\_type,  
:body =\> recipient[:file].read,  
:filename =\> recipient[:file].original\_filename  
end  
end

the mail is correct and the file is atached can anyone help me?

Sergio
