lib/javy_tool/utils.rb
# upload file,default to /tmp
# return filename
upload file,default to /tmp
return filename
upload file default to / tmp return filename
def upload_file(file,path=nil)
      path ||= JavyTool.options[:upload_path]
      unless file.original_filename.empty?
        filename = if block_given?
          yield file.original_filename
        else
          Time.now.strftime("%Y%m%d%H%M%S") + rand(10000).to_s + File.extname(file.original_filename)
        end
        File.open(path+filename, "wb") { |f| f.write(file.read) }
        filename
      end
    end
def upload_file ( file , path = nil ) path ||= JavyTool . options [ :upload_path ] unless file . original_filename . empty? filename = if block_given? yield file . original_filename else Time . now . strftime ( "%Y%m%d%H%M%S" ) + rand ( 10000 ) . to_s + File . extname ( file . original_filename ) end File . open ( path + filename , "wb" ) { | f | f . write ( file . read ) } filename end end
upload file,default to /tmp
return filename
upload file default to / tmp return filename
file
path