From aec9449771821b85cc22a1627b55504390ba94e1 Mon Sep 17 00:00:00 2001 From: Alexey Verkhovsky Date: Sat, 22 Jan 2005 18:38:16 +0000 Subject: [PATCH] Naive implementation of a file upload --- app/controllers/application.rb | 2 +- app/controllers/file_controller.rb | 14 ++++++++++++-- app/views/file/file.rhtml | 21 ++++++++++++++++++++- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/app/controllers/application.rb b/app/controllers/application.rb index a6200043..8de620c6 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -71,7 +71,7 @@ class ApplicationController < ActionController::Base not @web_name.nil? end - @@REMEMBER_NOT = ['locked', 'save'] + @@REMEMBER_NOT = ['locked', 'save', 'back'] def remember_location if @response.headers['Status'] == '200 OK' unless @@REMEMBER_NOT.include? action_name or @request.method != :get diff --git a/app/controllers/file_controller.rb b/app/controllers/file_controller.rb index f3bc9e5d..1a889142 100644 --- a/app/controllers/file_controller.rb +++ b/app/controllers/file_controller.rb @@ -7,14 +7,24 @@ class FileController < ApplicationController layout 'default' def file - if have_file? + if @params['file'] + # received a file + File.open(file_name) { |f| f.write(@params['file'].read } + + elsif have_file? send_file(file_path) else logger.debug("File not found: #{file_path}") - # to template, which is a file upload form + # go to the template, which is a file upload form end end + def cancel_upload + return_to_last_remembered + end + + def + private def have_file? diff --git a/app/views/file/file.rhtml b/app/views/file/file.rhtml index 0757e666..72da6721 100644 --- a/app/views/file/file.rhtml +++ b/app/views/file/file.rhtml @@ -1,3 +1,22 @@ +<% + @title = "Upload #{@file_name}" + @hide_navigatio = false +%> +

-TODO: Here should be a form for uploading files to Instiki +<%= form_tag({}, {:multipart => true}) %> +

+ File to upload: +
+ +

+

+ as + + <% if @page %> + | Cancel (unlocks page) + <% end %> +

+<%= end_form_tag %>

\ No newline at end of file