Cant upload file with mechanize

hy
i try to upload a file with mechanize but i dont understand why i cant ??
I try with two differents params name and id but each time i get an error.

*Code: *
agent = Mechanize.new{ |a| a.log = Logger.new("Mechanize.log") }
agent.read_timeout = 60
agent.user_agent_alias = 'Linux Mozilla'
        {
          'Linux Mozilla' => 'Mozilla/5.0 (X11; U; Linux i686; en-US;
rv:1.4) Gecko/20030624',
          'Linux Firefox' => 'Mozilla/5.0 (X11; U; Linux i686; en-US;
rv:1.9.2.1) Gecko/20100122 firefox/3.6.1'
         }

agent.get("http://XXXX")

         form = agent.page.parser.css('form')[0]
             agent.page.forms[0]["login"] = "login"
             agent.page.forms[0]["password"] = "password"
           res = agent.page.forms[0].submit

     #uploadFile = agent.click(res.link_with(:name => "file"))
     uploadFile = agent.click(res.link_with(:id => "filepc"))

*Error:* *with id *
/usr/local/rvm/gems/ruby-2.1.3/gems/mechanize-2.7.3/lib/mechanize.rb:354:in
`click': undefined method `[]' for nil:NilClass (NoMethodError)
    from mechanize.rb:33:in `<main>'

*Error*: with name
(eval):14:in `block (2 levels) in links_with': undefined method `name' for
#<Mechanize::Page::Link "

*HTML code *:

<div class="upload_input">
    <input id="filepc" type="file" size="79"
onchange="this.form.fakeupload.value = this.value;" name="file"></input>
</div>