diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 00a71ed..64f4449 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,18 +2,10 @@ - - - - - - - - + - @@ -31,7 +23,7 @@ - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -52,34 +68,21 @@ - - + + - - + + - - + + - - - - - - - - - - - - - - - + + @@ -102,6 +105,7 @@ @@ -190,7 +194,15 @@ \ No newline at end of file diff --git a/app/controllers/micro_posts_controller.rb b/app/controllers/micro_posts_controller.rb index 3255ca8..673a0dd 100644 --- a/app/controllers/micro_posts_controller.rb +++ b/app/controllers/micro_posts_controller.rb @@ -1,6 +1,7 @@ class MicroPostsController < ApplicationController before_action :logged_in_user + micro_posts_dir = "public/data" def show @user = current_user @@ -13,6 +14,13 @@ class MicroPostsController < ApplicationController post_type = params[:post_type].to_i title = params[:title].to_s content = params[:content].to_s + pictures = params[:pictures] + pictures.each do |pic| + pic.original_filename + ext = File.extname(pic.original_filename) + save_name = Digest::MD5::hexdigest(pic.original_filename) + ext + p save_name + end if post_type >= 1 and post_type <= 3 and !title.empty? and !content.empty? micropost = @user.micro_posts.new(content:content,post_time:DateTime.now,title:title, diff --git a/app/views/micro_posts/show.html.erb b/app/views/micro_posts/show.html.erb index 620ae3b..02475fc 100644 --- a/app/views/micro_posts/show.html.erb +++ b/app/views/micro_posts/show.html.erb @@ -14,7 +14,7 @@ 发布新信息 - <%= form_tag("/newpost", method: "post", class: "form-horizontal") do %> + <%= form_tag("/newpost", method: "post", class: "form-horizontal", enctype: "multipart/form-data") do %>
@@ -39,10 +39,12 @@
当前选择上传0个图片
-   +
+ +
@@ -86,14 +88,15 @@