hit4

xiaoxiao2022-06-14  42

class FileUpload < ActiveRecord::Base has_attachment :size => 1..1.megabyte, :path_prefix => "public/uploadedfiles", :storage => :file_systemendclass PostController < ApplicationController def new_upload_file @upload_file=FileUpload.new @files=FileUpload.find :all end def do_upload @attachable_file=FileUpload.new params[:upload_file] if @attachable_file.save flash[:notice]="Uploaded successfully." redirect_to :action => :new_upload_file end endend<% if flash[:notice] %> <%= flash[:notice] %><% end %><% form_for(:upload_file,:url => {:action => "do_upload"}, :html => {:multipart => true}) do |form| %> <%= form.file_field :uploaded_data,:size => 50 %> <%= submit_tag " 上传 " %><% end %>
转载请注明原文地址: https://www.6miu.com/read-4936712.html

最新回复(0)