[要旨] responseText は問題なく使えるのに、なぜか responseXML を使おうとすると問題が発生します。 [キーワード] Internet Explorer,Firefox,FireBug
■画面遷移無しでファイルアップロード Railsでファイルアップロードを行うには、FORMを下記のように準備すれば、 <%= form_tag({:action=>'upload'},:multipart=>true) %> <%= file_field 'attached_file', 'attached_file','size'=>29 %> file = params[:attached_file]で受け取り、file.readをFileなりDB格納できますが、FORMで他のテキストを編集させる兼ね合いでページ遷移を発生させたくありませんでした。 ■通常のFORMタグでAjax風の操作感を実現 RailsにはAjaxに対応したform_remote_tagがありますが、残念ながら:multipartの指定ができません。セキュリティ上の制約によりjavascript ではローカルファイ
This page is a complete mess! However, it is updated with a working example, compatible with Rails 2.0.2 below. See also the Rails cookbook: Sending and receiving files Example of file saving model (based on Rails Cookbook). This works with Rails 2.0.2, and requires no special modification to controller code. Just make sure your form in the view has :html => { :multipart => true} and that your fi
以下本、P466の応用。本ではDBに画像データを保存してしまっているが、以下例ではDBには画像パスのみを指定し、publicフォルダ配下に画像データを保存する。 DBは事前に作成してあるものとする。 DB作成する 1. db/migrate/001_create_pictures.rb 作成 class CreatePictures < ActiveRecord::Migration def self.up create_table :pictures do |t| t.column :comment, :string t.column :name, :string t.column :content_type, :string t.column :file_url, :string end end def self.down drop_table :pictures end end 2.
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く