Is there a way to retrieve a file off the server or hard drive? I have a program that creates a file and I would like a button to retrieve the file so the user can save it somewhere. Not ajax right now.
Me wrote:
Is there a way to retrieve a file off the server or hard drive? I have a program that creates a file and I would like a button to retrieve the file so the user can save it somewhere. Not ajax right now.
# view
<%=button_to "Download File", :action=>'download'%>
# controller
def download send_file(path_to_file, :disposition => :attachment) end
send_file documentation http://railsmanual.org/module/ActionController::Streaming/send_file/1.1.2