Plack::...:Upload(3)

πŸ’– Plack::Request::Upload πŸ’–

okay so bestie, welcome to Plack::Request::Upload β€” the module that handles file upload requests. yes, THE file upload module, the one your form goes through when someone drops a pic into your webapp. no cap, it's giving backend royalty πŸ‘‘

this lil page is from the User Contributed Perl Documentation, so it's iykyk territory 🫢


✨ SYNOPSIS ✨

so like, here's the vibe in code form, mkay:

# $req is Plack::Request
my $upload = $req->uploads->{field};

$upload->size;
$upload->path;
$upload->content_type;
$upload->basename;

$req is a Plack::Request, and you pull your upload out of $req->uploads->{field} like it's a lil gift 🎁 then you can poke at it with all the methods below. slay.


🌸 METHODS 🌸

  • size β€” returns the size of the Uploaded file. that's it, that's the method. how big is your file, bestie? this tells you πŸ’…
  • path β€” returns the path to the temporary file where the uploaded file is saved. so like, the file doesn't live where the client said it lives, it lives in a temp spot, and this is where you find it πŸ¦‹
  • content_type β€” returns the content type of the uploaded file. the MIME type, the vibe check of the file, what kind of thing it is ✨
  • filename β€” returns the original filename in the client. as in, whatever the client claimed the name was, untouched, no sanitising, raw as it gets πŸ™ˆ
  • basename β€” returns basename for "filename". and here's the tea 🍡 characters other than word characters, "." and "-" get replaced with "_", and a name that would come out empty, "." or ".." gets returned as "_".
⚠️ ok so listen, this is important: the returned value is still client-supplied. you should make sure it doesn't overwrite existing files before using it as a file name. fr fr, do NOT just trust it. it's giving "user input, handle with care" πŸ˜­πŸ”’

πŸ‘‘ AUTHORS πŸ‘‘

  • Kazuhiro Osawa
  • Tatsuhiko Miyagawa

absolute icons, both of them. we stan 🫢


🌈 SEE ALSO 🌈

  • Plack::Request
  • Catalyst::Request::Upload

go read those next bestie, they're in the same friend group πŸ’œ


and that's the whole page!! this was perl v5.42.3, dated 2026-10-18, and it's the Plack::...:Upload(3) manpage, mwah πŸ’‹ go forth and handle those uploads responsibly, k? βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from