ubuntu, ror, jQuery, css, website memo
太嫩, 沒啥心得, 用來紀錄每天學的
2008年11月27日 星期四
超簡單 very simple merb upload file
http://blog.vixiom.com/2007/06/29/merb-on-air-drag-and-drop-multiple-file-upload/
http://iceskysl.1sters.com/?action=show&id=368&page=1
http://www.mikeperham.com/2007/10/02/file-uploads-in-merb-versus-rails/
<br />class Attachment<br /> include DataMapper::Resource<br /><br /> property :id, Serial<br /> property :filename, String<br />end<br />
<br />class Upload < Application<br /><br /> # ...and remember, everything returned from an action<br /> # goes to the client...<br /> def index <br /> render<br /> end<br /><br /> def upload<br /> puts params.inspect<br /> #new user file object<br /> @upload = Attachment.new<br /> @upload.filename = params[:file][:filename]<br /><br /> # save<br /> if @upload.save<br /> FileUtils.mv params[:file][:tempfile].path, "#{Merb.root}/public/upload/#{params[:file][:filename]}"<br /> else <br /> false<br /> end<br /> end<br />end<br />
<br /><%= form :action => url(:controller => "upload", :action => "upload") do %><br /> <%= file_field :file, :label => "Filename" %><br /> <%= submit "Create" %><br /><% end =%><br />
沒有留言:
張貼留言
較新的文章
較舊的文章
首頁
訂閱:
張貼留言 (Atom)
Tweet
t
沒有留言:
張貼留言