# File\_field and Firefox

**URL:** <https://www.ruby-forum.com/t/file-field-and-firefox/53457>\
**Category:** Rails\
**Created:** [February 6, 2006, 4:02pm UTC](https://www.ruby-forum.com/t/file-field-and-firefox/53457 "2006-02-06T16:02:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![marek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b2d939/32.png) [@marek](https://www.ruby-forum.com/u/marek)\
**Post date:** [February 6, 2006, 4:02pm UTC](https://www.ruby-forum.com/t/file-field-and-firefox/53457/1 "2006-02-06T16:02:43Z")

</div>

Hi!  
Im developing a simple prototype of an application. It fills an oracle  
db with data about a file in the filesystem, and save the entire file  
in a blob along with some metadata. To get the file in the db i use a  
file\_field form helper. All goes well with the radrails-integrated  
browser, but it doesnt work anymore in firefox. The problem is,  
firefox seems to cut the pathname from the file.

Here is the right hash from radrails:  
“upload”=\>  
“C:\Documents and Settings\All Users\Documenti\Web  
Development\contrattositoweb.pdf”,

Here is firefox one:  
“upload”=\>“contrattositoweb.pdf”

That leads at:  
Errno::ENOENT in Documents#create

No such file or directory - contrattositoweb.pdf

The important part of the code is, for the view:

Content  
\<%= file\_field 'document', 'upload' %\>

and in the model document.rb:

def upload=(upload\_field)  
self.filename=upload\_field  
self.content\_type=MIME::Types.type\_for(upload\_field)  
File.open(upload\_field, “rb”) { |f| #ERROR  
HERE  
self.filename=File.basename(upload\_field)  
self.content=f.read  
}  
end

def base\_part\_of(file\_name)  
name=File.basename(file\_name)  
name.gsub(/[^\w.\_-]/,’’)  
end

As far as i know im not calling any filename-modder in the model, so  
maybe the problem is in the view?

Thanks in advance for all helps…

–  
Maurizio Marek  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![marek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b2d939/32.png) [@marek](https://www.ruby-forum.com/u/marek)\
**Post date:** [February 6, 2006, 7:16pm UTC](https://www.ruby-forum.com/t/file-field-and-firefox/53457/2 "2006-02-06T19:16:49Z")

</div>

[http://sean.treadway.info/articles/2005/06/22/upload-progress-stabilizing](http://sean.treadway.info/articles/2005/06/22/upload-progress-stabilizing)  
Could this help?  
I don’t know what it does, but if it does an upload with firefox  
successfuly  
in their demo, maybe you could find what they are doing differently?

---

<div class="post-metadata">

**Author:** ![marek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b2d939/32.png) [@marek](https://www.ruby-forum.com/u/marek)\
**Post date:** [February 6, 2006, 8:00pm UTC](https://www.ruby-forum.com/t/file-field-and-firefox/53457/3 "2006-02-06T20:00:28Z")

</div>

I’ll check it out, thanks!

2006/2/6, anne g [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> [http://sean.treadway.info/articles/2005/06/22/upload-progress-stabilizing](http://sean.treadway.info/articles/2005/06/22/upload-progress-stabilizing)  
> Could this help?  
> I don’t know what it does, but if it does an upload with firefox successfuly  
> in their demo, maybe you could find what they are doing differently?
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

–  
Maurizio Marek  
removed\_email\_address@domain.invalid
