diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 49de7af..20b15e5 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -14,4 +14,12 @@ class HomeController < ApplicationController `mkdir #{current_dir}/#{directory_name}` redirect_to '/home/index' end + + + def delete_file + file_name = params[:file_name] + puts "rm #{file_name} -rf" + #`rm #{file_name} -rf` + redirect_to '/home/index' + end end diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 64cb5ff..78299e9 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -207,15 +207,24 @@ ShowContextMenu("Del_dir"); var Row = this; var Cells = Row.getElementsByTagName("td"); - var text = Cells[0].innerText; - $("#delete_name").val(text); + var file_name = Cells[0].innerText; + file_name = file_name.replace(' ', ''); + $("#delete_name").val($("#select_dir").text() + "/" + file_name); CheckLocation(); return false; }); } $(".Del_dir").click(function(e){ - alert($("#delete_name").val()); + $.ajax({ + method: "POST", + url: "/home/delete", + data: { file_name: $("#delete_name").val() }, + success : function(result){ + + //alert("aa"); + } + }) $(".contextmenu").hide(); $(document).unbind('mousedown'); }); diff --git a/config/routes.rb b/config/routes.rb index 8930423..9604c8f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -13,6 +13,7 @@ Rails.application.routes.draw do #Home get 'home/index' => 'home#index' post 'home/mkdir' => 'home#make_directory' + post 'home/delete' => 'home#delete_file' #Volume