如何使用 Catalyst 上传文件?
我正在开发一个基于内部网络的应用程序,用于存储和编目照片。 我应该如何检索这些文件并将其保存到服务器?
注意:我想将文件保存到文件系统,而不是数据库。
类似于如何处理 HTTP 文件上传?< /em>
I am working on an internal web based application for storing and cataloging photos. How should I retrieve, and save these files to the server?
Note: I want to save the files to the file system, not to a database.
Similar to How can I handle HTTP file uploads?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从 HTML 表单上您熟悉的上传输入开始,并确保 HTML 表单标记具有参数
enctype="multipart/form-data"
您的 Catalyst::Request 对象 (
$c->request
) 提供两种访问和操作文件的方法。每个文件上传字段将被实例化为 Catalyst::Request::Upload 对象。
$c->request->upload
将以标量或列表形式返回 Upload 对象。$c->request->uploads
将返回对 Upload 对象的哈希值的引用。Upload 对象提供了多种保存和复制文件的方法。
查看我上面链接的手册页。
Start with your familiar upload INPUT on your HTML form and ensure that the HTML form tag has the parameter
enctype="multipart/form-data"
Your Catalyst::Request object (
$c->request
) provides two methods for accessing and manipulating the files.Each file upload field will be instantiated as a Catalyst::Request::Upload object.
$c->request->upload
will return the Upload objects in scalar or list form.$c->request->uploads
will return a reference to hash of Upload objects.The Upload object provides several method for saving and copying the files.
Check out the man pages that I've linked above.