有人能告訴我如何用send_file
下載文件?如何使用send_file下載文件?
我有一個文件image.jpg
裏面app/assets/images
。我在我的控制器嘗試這樣:
def download
send_file ("#{Rails.root}/public/images/image.jpg")
end
def download
send_file ("#{Rails.root}/assets/images/image.jpg")
end
def download
send_file ("#{Rails.root}/images/image.jpg")
end
def download
send_file ("/public/images/image.jpg")
end
def download
send_file ("/assets/public/images/image.jpg")
end
def download
send_file ("/assets/images/image.jpg")
end
對於每條路徑,它說:
ActionController::MissingFile in HomeController#download
Cannot read file 'some_path'
什麼可以在這裏是一個問題?謝謝!
謝謝你的建議,但它是一樣的。找不到文件。 – user3339562
即使在/ public/images目錄中存在image.jpg文件,也會出現此錯誤?也許嘗試重新啓動你的應用服務器。這應該肯定會起作用。 – Coenwulf