Dancer...:Upload(3pm)

✨ NAME ✨

Dancer::Request::Upload β€” the class that's literally the whole vibe for file upload requests πŸ’…

It lives in the Dancer...:Upload(3pm) corner of the Perl universe (okay bestie, that's Dancer::Request::Upload β€” the header just did a little truncation thing, iykyk).

πŸŽ€ VERSION πŸŽ€

version 1.3522 ✨

πŸ¦‹ SYNOPSIS πŸ¦‹

So picture this, bestie: you want your users to hand you a file. First, some HTML doing its little thing in your view:

# somewhere in your view:
<form action="/upload" method="POST" enctype="multipart/form-data">
  <input type="file" name="filename">
  <input type="submit">
</form>

Then in your application handler you just… grab it. No cap:

# and then in your application handler:
post '/upload' => sub {
  my $file = request->upload('filename');
  $file->copy_to($upload_dir);  # or whatever you need
};

That's it. That's the whole flow. Slay. πŸ‘‘

🌸 DESCRIPTION 🌸

This class is the representation of file uploads for Dancer, fr fr. Like, someone uploads a file and this object is what you get to play with.

You reach these objects from inside route handlers via the request->uploads keyword. Wanna know more? Go read Dancer::Request. It's giving documentation excellence.

πŸ’– METHODS πŸ’–

  • filename β€” hands you the filename exactly as the client sent it. The raw, unfiltered truth.
  • basename β€” the basename for filename. It strips it down to just the last chunk, the way you'd expect.
  • tempname β€” the name of the temporary file where the data got saved. Heads up though: it'll be sitting in e.g. /tmp, it gets a random name, and it has no file extension. Just so you're not out here searching for a .jpg that will never arrive. 😭
  • link_to β€” makes a hard link to the temporary file. Returns true if it worked, false if it didn't. That's it, that's the deal.
$upload->link_to('/path/to/target');
  • file_handle β€” gives you a read-only file handle on the temporary file. Read-only, bestie. Don't try to write through it.
  • content β€” returns a scalar containing the contents of the temporary file. The whole thing. In memory. You've been warned. πŸ’€
  • copy_to β€” copies the temporary file using File::Copy. Returns true for success, false for failure.
$upload->copy_to('/path/to/target')
  • size β€” the size of the upload, in bytes. πŸ“
  • headers β€” returns a hash ref of the headers associated with this upload.
  • type β€” the Content-Type of this upload. The whole "what even is this file" question, answered. ✨

🫢 AUTHORS 🫢

This module has been written by Alexis Sukrieh, heavily based on Plack::Request::Upload. Kudos to the Plack authors β€” iconic behavior, we love to see it. πŸ₯Ή

⭐ SEE ALSO ⭐

  • Dancer

πŸ‘‘ AUTHOR πŸ‘‘

Dancer Core Developers

This software is copyright (c) 2010 by Alexis Sukrieh.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


Okay so that's the whole page, bestie β€” and a lil' sign-off moment: this was Dancer...:Upload(3pm) from the user contributed Perl documentation, built off perl v5.40.1, dated 2026-05-05. Go upload something cute. πŸŽ€πŸŒˆπŸ¦‹

πŸ“¦ where this page comes from