first upload working (wip)
This commit is contained in:
@ -3,12 +3,26 @@ module Cms
|
||||
class ImageController < ApplicationController
|
||||
|
||||
@@root = "app/assets/images/cms/"
|
||||
@@files = Dir.new(Rails.root + @@root).children
|
||||
@@files = Set.new Dir.new(Rails.root + @@root).children
|
||||
|
||||
def index
|
||||
@files = files
|
||||
end
|
||||
|
||||
def new
|
||||
end
|
||||
|
||||
def create
|
||||
io = params['image_file']
|
||||
ending = io.original_filename.split("/").last.split(".").last
|
||||
filename = params['filename'] + "." + ending
|
||||
File.open(Rails.root.join('app/assets/images/cms', filename), "wb") do |f|
|
||||
f.write io.read
|
||||
end
|
||||
@@files << filename
|
||||
redirect_to cms_image_index_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def files
|
||||
|
Reference in New Issue
Block a user