Rails 中的图像上传
如何在 RoR 中上传图像和 zip 文件? 我是新手。 所以请帮忙。 给我视图和控制器代码示例。
提前致谢。
How do I upload images and zip files in RoR? I am a newbie. So please help.
Give me both the view and the controller code example.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
ImageMagick 也很酷
ImageMagick is also pretty cool
我会推荐回形针,以及允许您将内容存储在数据库而不是文件系统中的补丁
http ://patshaughnessy.net/paperclip-database-storage
该链接包含您正在寻找的视图和控制器示例
I would recommend paperclip, and the patch that allows you to store the content in the database instead of the file system
http://patshaughnessy.net/paperclip-database-storage
the link has the view and controller examples that you are looking for
我更喜欢Carrierwave,因为它可以轻松上传图像。
这是 github 页面 和 railscasts 页面 用于快速启动。
I prefer carrierwave is better to upload images easily.
Here's github page , and railscasts page for quick start.
一种选择是 attachment_fu。 它允许您将上传的文件保存到文件系统、数据库或 Amazon S3。 它还允许您选择使用哪个图像处理器,例如 RMagick 或 Minimagick。
该链接提供了比我在这里提供的更好的代码。
One option is attachment_fu. It allows you to save your uploaded file to the filesystem, database, or Amazon S3. It also allows you to select which image processor is used, such as RMagick or Minimagick.
The link provides better code than I could here.
导航,
尝试回形针插件,您可以在这里阅读它 http://www.thoughtbot.com/projects/回形针
Nav,
Try the paperclip plugin, you can read about it here http://www.thoughtbot.com/projects/paperclip
我们更喜欢 CarrierWave 在 Rails 中上传图像。 非常容易集成并且非常模块化。
以下文章介绍了使用 CarrierWave 上传图像的解决方案,同时图像转换在云中无缝完成。 上传的图像存储在云端并通过 CDN 传送。
无需安装 RMagick、MiniMagick 和 ImageMagick。
We prefer CarrierWave for image uploads in Rails. Very easy to integrate and very modular.
The following post describes a solution for image uploading using CarrierWave while image transformations are done seamlessly in the cloud. Uploaded images are stored in the cloud and delivered through a CDN.
No need to install RMagick, MiniMagick and ImageMagick.
http://cloudinary.com/blog/ruby_on_rails_image_uploads_with_carrierwave_and_cloudinary
建议查看 Railscast 的 paperclip。
suggest checking out the Railscast for paperclip.