Rails 3 - upload files to public directory

前端 未结 3 1380
你的背包
你的背包 2020-12-02 10:34

I\'m looking for a simple way to upload a file (an xml file) to the public directory of Rails 3. Once it\'s there I want to open it, parse the contents and delete the file a

3条回答
  •  再見小時候
    2020-12-02 11:20

    img = params[:user][:photo]
    File.open(Rails.root.join('public','uploads',img.original_filename),'wb') do |file| file.write(img.read)
    

提交回复
热议问题