Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I upload a file using Catalyst?

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?

like image 449
Brad Gilbert Avatar asked Dec 03 '08 15:12

Brad Gilbert


People also ask

How do I upload a file to VSC?

To upload a file, supplying a user name and passwordUse the UploadFile method to upload a file, specifying the source file's location and the target directory location as a string or URI, and specifying the user name and the password. This example uploads the file Order.

What is a catalyst file?

Catalyst File Store provides cloud storage solutions to store, manage, and organize your application files and user data files. The files can be images, videos, text files, document files, spreadsheets, or other formats. Catalyst provides storage for all file formats and helps you categorize them in folders.


1 Answers

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.

like image 51
Len Jaffe Avatar answered Sep 28 '22 11:09

Len Jaffe