我用如下代码,想实现强制下载,但总是报错:
Cannot read file /uploads/video/4f03eae211aa2b21b1000fa5/aaa.mp4
view:
<%= link_to "下载", { :action => "download", :id => @video.id } %>
controller:
def download
@video = Video.find(params[:id])
if @video.blank?
render_404
end
@video.download = @video.download + 1
@video.save
send_file @video.file_url, :type => 'application/octet-stream', :disposition => 'inline'
end
而直接在 view 里
<%= link_to "下载", @video.file_url %>
是可以访问的。 请教同学们,问题出在哪儿呢?