Mojo::Upload(3)
π Mojo::Upload β¨
Okay bestie, so Mojo::Upload is literally a container for uploaded files β that's the whole vibe from the Mojo::Upload man page (section three of the manual, iykyk). It's giving "glorified box that holds your upload" and honestly? We stan a simple, focused icon. π
πΈ SYNOPSIS πΈ
Like, here's the whole thing in action:
use Mojo::Upload;
my $upload = Mojo::Upload->new;
say $upload->filename;
$upload->move_to('/home/sri/foo.txt');
Not me making a whole object and then immediately yeeting the file to /home/sri/foo.txt π iconic behavior honestly.
π¦ DESCRIPTION π¦
Mojo::Upload is a container for uploaded files. That's it, that's the tweet. It holds your uploaded file data and lets you poke at it. Main character energy, minimal lore. β¨
π ATTRIBUTES π
Mojo::Upload implements the following attributes β aka the little properties you can get and set, bestie:
π asset
my $asset = $upload->asset;
$upload = $upload->asset(Mojo::Asset::File->new);
This is the asset containing the uploaded data β like, the actual stuff. Usually it's a Mojo::Asset::File or a Mojo::Asset::Memory object, depending on how big and how dramatic your upload is being. πΎ
π§ filename
my $filename = $upload->filename;
$upload = $upload->filename('foo.txt');
Name of the uploaded file. Yeah, the whole "what is this file even called" situation. Get it, set it, live your truth. π·οΈ
π headers
my $headers = $upload->headers;
$upload = $upload->headers(Mojo::Headers->new);
Headers for the upload β usually a Mojo::Headers object, because even uploads have to introduce themselves properly. π«Ά
β name
my $name = $upload->name;
$upload = $upload->name('foo');
Name of the upload. Yes, it's different from filename β one is the upload's name, one is the file's name. Sibling energy, not the same thing. π
π₯ METHODS π₯
Mojo::Upload inherits all methods from Mojo::Base and implements the following new ones. Slay, inheritance. π
π move_to
$upload = $upload->move_to('/home/sri/foo.txt');
Move uploaded data into a specific file. Physically relocating your bytes to their new home at /home/sri/foo.txt. Good luck out there little bytes π«‘
π size
my $size = $upload->size;
Size of uploaded data in bytes. Numbers! Real ones! In bytes, specifically. π
π¦ slurp
my $bytes = $upload->slurp;
Read all uploaded data at once. Every last byte, in one single gulp β hence the name, she's a little thirsty but she delivers. π₯€
π SEE ALSO π
- Mojolicious
- Mojolicious::Guides
- <https://mojolicious.org>
Go read the guides bestie, they're literally right there. π
Reminder: this is the Mojo::Upload(3) page, hanging out with the rest of the user contributed Perl documentation. π«Ά
And that's a wrap, bestie! π This page is from perl v5.42.0, dated 2026-07-15 β so go forth, move files, read bytes, and remember: no cap, you understood all of this. π
β¨π
π¦ where this page comes from
- opensuse-leap 16.0: perl-Mojolicious 9.480.0-bp160.2.1 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms