用Paperclip获取服务器文件路径 [英] Get server file path with Paperclip
问题描述
有人现在怎么做到这一点? 假设你在用户的实例上有一个名为avatar的附件,你可以使用 user.avatar.path
获得文件系统上文件的完整路径,你可以使用 user.avatar.url
给你可以在图片标签和whatnot中使用的路径。
这就是你'是什么意思?
I'm using Rails with Paperclip to make a small file upload app. I would like to be able to return the file path on the server of the uploaded file once its done but I can't seem to work out how to get the path? Paperclip only seems to record the name of the file itself.
Does anybody now how to do this?
Assuming you had an attachment called avatar on an instance of a user, you can use user.avatar.path
to get the full path of the file on the filesystem, and you can use user.avatar.url
to give the path which you could use in image tags and whatnot.
Is that what you're meaning?
这篇关于用Paperclip获取服务器文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!