谁能建议我在 CakePHP 中编写用于上传文件的代码的最佳方法?
Can any one suggest me the best way to write code for uploading a file in CakePHP?
afterSave回调中上传文件afterSave callbackEdit (2015): 请参阅 Awesome CakePHP 当前文件插件列表(2.x 分支 这里)
Edit (2015): Please see the Awesome CakePHP list for current file plugins (2.x branch here)
编辑(2013 年):这个答案现在有点过时了,所以我只留下所有提到的上传插件的列表:
Edit (2013): This answer is now a bit dated, so I will just leave a list of all mentioned upload plugins:
原始答案(来自 2010 年):
Original answer (from 2010):
您可以考虑使用在上一届 CakeFest 上讨论过的媒体插件.它相当全面,包含诸如创建文件变体(即图像或视频的缩略图)、输出不同类型文件的助手以及帮助更快创建多文件上传表单的元素等功能;并且从一开始就非常关注安全性,因为我可以从 幻灯片中收集到.我在生产中使用它并发现它运行良好,而且它似乎处于更多积极开发 比我见过的其他选项是否有任何意义(例如 MeioUpload 行为、上传插件、FileUpload 插件 以及有关该主题的各种 Bakery/博客文章).
You might consider using the Media plugin that was talked about at the last CakeFest. It is fairly comprehensive, containing features such as creating file variations (ie. thumbnails of images or video), helpers for outputting different types of files, and elements to help create multiple-file upload forms more quickly; and also had a strong focus on security from the outset as I can gather from the slides. I use it in production and find it works well, plus it seems to be under more active development than other options I have seen if that's anything to go by (eg. MeioUpload behavior, Uploader plugin, FileUpload plugin and various Bakery/blog posts on the topic).
这篇关于在 CakePHP 中上传文件的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
不能使用 'Object 作为类名,因为它是保留的Cannot use #39;Object as class name as it is reserved Cake 2.2.x(不能使用 Object 作为类名,因为它是保留的 Cake 2.2.x)
OAuth 重定向后会话丢失Session is lost after an OAuth redirect(OAuth 重定向后会话丢失)
Cakephp 3.x 中的分页排序Pagination Sort in Cakephp 3.x(Cakephp 3.x 中的分页排序)
CakePHP 多个应用程序的共享核心CakePHP Shared core for multiple apps(CakePHP 多个应用程序的共享核心)
在 CakePHP 3 上登录 [ Auth->identify() ] 始终为 falLogin [ Auth-gt;identify() ] always false on CakePHP 3(在 CakePHP 3 上登录 [ Auth-identify() ] 始终为 false)
致命错误:允许的内存大小为 134217728 字节已用尽Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 87 bytes)(致命错误:允许的内存大小为 134217728 字节已用尽