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/
class Attachment
include DataMapper::Resource
property :id, Serial
property :filename, String
end
class Upload < Application
# ...and remember, everything returned from an action
# goes to the client...
def index
render
end
def upload
puts params.inspect
#new user file object
@upload = Attachment.new
@upload.filename = params[:file][:filename]
# save
if @upload.save
FileUtils.mv params[:file][:tempfile].path, "#{Merb.root}/public/upload/#{params[:file][:filename]}"
else
false
end
end
end
<%= form :action => url(:controller => "upload", :action => "upload") do %>
<%= file_field :file, :label => "Filename" %>
<%= submit "Create" %>
<% end =%>
沒有留言:
張貼留言
較新的文章
較舊的文章
首頁
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言