diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index f6d7e14..c3d0cc0 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,19 +1,16 @@ class HomeController < ApplicationController def index - config = get_conf - #@current_dir = config["project_path"] @current_dir = "/mnt" file_directory(@current_dir) end def file_download - @file_name = params[:file_name] - puts "file_name: " + @file_name - if File.exist?(@file_name) - #File.delete(@file_name) - puts "file exist!!" - send_file(@file_name) - puts "send success" + @file_name = params[:file_name].gsub(" ", "/") + if !@file_name.nil? + send_file @file_name + else + puts "file name is nil" + redirect_to '/home/index' end end diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 0eb37ac..da9e8bd 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -162,11 +162,7 @@ <% else %> -
- - - -
+ "><%=t['name']%> <% end %> <%=t["auth"]%> @@ -279,11 +275,7 @@ function change_directory(directory){ new_tr += "" + result.file[i].name + ""; }else{ new_tr += ""; - new_tr += "
"; - new_tr += ""; - new_tr += ""; - new_tr += ""; - new_tr += "
"; + new_tr += "" + result.file[i].name + "" new_tr += ""; } new_tr += ""+result.file[i].auth+""; @@ -296,45 +288,16 @@ function change_directory(directory){ $("#table_div").append(new_table); $('#datatable').dataTable(); right_click(); - - $(".form_file_download").submit(function(){ - file_name = $(this).find("input").val(); - $.ajax({ - type: 'post', - url: '/file_download', - data: {file_name: file_name}, - success: function(result){ - console.log("post success"); - } - }); - return false; - }) } }) } - -