Naive implementation of a file upload

This commit is contained in:
Alexey Verkhovsky 2005-01-22 18:38:16 +00:00
parent e6c32bafc6
commit aec9449771
3 changed files with 33 additions and 4 deletions

View file

@ -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

View file

@ -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?

View file

@ -1,3 +1,22 @@
<%
@title = "Upload #{@file_name}"
@hide_navigatio = false
%>
<p>
TODO: Here should be a form for uploading files to Instiki
<%= form_tag({}, {:multipart => true}) %>
<p>
File to upload:
<br/>
<input type="file" name="file" size="40">
</p>
<p>
<input type="submit" value="Update"> as
<input type="text" name="author" id="authorName" value="<%= @author %>"
onClick="this.value == 'AnonymousCoward' ? this.value = '' : true">
<% if @page %>
| <a href="../file/">Cancel</a> <small>(unlocks page)</small>
<% end %>
</p>
<%= end_form_tag %>
</p>