Forum: Ruby on Rails File_field and Firefox

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Marek (Guest)
on 2006-02-06 17:02
(Received via mailing list)
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:

<p><label for="document_data">Content</label><br/>
<%= file_field 'document', 'upload' %></p>

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
anne g (Guest)
on 2006-02-06 20:16
(Received via mailing list)
http://sean.treadway.info/articles/2005/06/22/uplo...
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?
Marek (Guest)
on 2006-02-06 21:00
(Received via mailing list)
I'll check it out, thanks!

2006/2/6, anne g <removed_email_address@domain.invalid>:
> http://sean.treadway.info/articles/2005/06/22/uplo...
> 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
>


--
Maurizio Marek
removed_email_address@domain.invalid
This topic is locked and can not be replied to.