一个简单的后台上传学校logo的页面.

This commit is contained in:
Wen 2014-04-28 16:13:37 +08:00
parent 03d58b962a
commit 10fdcbb050
4 changed files with 30 additions and 2 deletions

View File

@ -2,6 +2,28 @@ class SchoolController < ApplicationController
before_filter :require_admin, :only => :upload_logo
def upload
uploaded_io = params[:logo]
school_id = 0
schools = School.where("name = ?", params[:school])
schools.each do |s|
school_id = s.id
end
unless uploaded_io.nil?
File.open(Rails.root.join('public', 'images', 'school', school_id.to_s+'.png'), 'wb') do |file|
file.write(uploaded_io.read)
end
s1 = School.find(school_id)
s1.logo_link = '/images/school/'+school_id.to_s+'.png'
s1.save
end
end
def upload_logo
end

View File

@ -1 +1,5 @@
<input type="file" />
<%= form_tag({action: :upload},method: "post", multipart: true) do %>
<%= text_field_tag 'school'%>
<%= file_field_tag 'logo' %>
<%= submit_tag('Upload') %>
<% end %>

View File

@ -588,6 +588,8 @@ RedmineApp::Application.routes.draw do
post 'school/search_school/', :to => 'school#search_school'
get 'school/search_school/', :to => 'school#search_school'
post 'school/upload', :to => 'school#upload'
######added by nie
match 'tags/show_projects_tags',:to => 'tags#show_projects_tags'
########### added by liuping

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB