Naive implementation of a file upload
This commit is contained in:
parent
e6c32bafc6
commit
aec9449771
|
@ -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
|
||||
|
|
|
@ -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?
|
||||
|
|
|
@ -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>
|
Loading…
Reference in a new issue