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 forfilename. 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.jpgthat 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 usingFile::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β theContent-Typeof 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
π COPYRIGHT AND LICENSE π
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
- ubuntu stonking: libdancer-perl 1.3522-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms