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 πŸ’–

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