Forum: Rails France file_field

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.
Rémi R. (Guest)
on 2007-07-18 18:08
Bonjour à tous,
je voudrai faire un truc simple : uploader un fichier sur mon server web

j'ai donc :

new_upload.rhtml :

<%= start_form_tag({:action => 'sendfile'}, :multipart => true) %>

Choose File:<br />
<%= file_field('upload', 'data', :size => '20') %><br />

<%= submit_tag('Upload') %>
<%= end_form_tag %>

admin_controller.rb :

class AdminController < ApplicationController

  def sendfile()
    path = "/public/admin/" + params[:upload][:data].original_filename
    data = params[:upload][:data].read
    f1 = File.new(path, "wb")
    f1.write(data)
    f1.close
    redirect_to :action=>"new_upload"
  end
end

Si j'upload un fichier texte pas de pb ça fonctionne.
Si j'upload autre chose (.jpg, .doc, ...) j'ai une erreur

Not Found
`/admin/sendfile' not found.
WEBrick/1.3.1 (Ruby/1.8.5/2007-06-28) at localhost:3000

auriez vous une idée ?
Merci d'avance
This topic is locked and can not be replied to.