Sha256: dfa355e1fc68728f2a7eb6c080d368b312dc73d9a9a2208b2bb31dafee090e48

Contents?: true

Size: 764 Bytes

Versions: 3

Compression:

Stored size: 764 Bytes

Contents

$:.unshift( "../lib" )
require 'capcode'
require 'rubygems'
require 'fileutils'

module Capcode
  class Index < Route '/'
    def get
      render :markaby => :index
    end
    
    def post
      FileUtils.cp( 
        params["upfile"][:tempfile].path, 
        File.join( static[:path], params["upfile"][:filename] )
      )
      render :static => params["upfile"][:filename]
    end
  end
end

module Capcode::Views
  def index
    html do
      body do
        h1 "Upload..."
        form :method => "POST", :enctype => 'multipart/form-data' do
          input :type => "file", :name => "upfile"; br
          input :type => "submit", :value => "Upload"
        end
      end
    end
  end
end

Capcode.run( :static => "data" ) {
  FileUtils.mkdir_p 'data'
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
Capcode-0.9.3 examples/upload.rb
Capcode-0.9.2 examples/upload.rb
Capcode-0.9.1 examples/upload.rb