6161
Simple Mojolicious::Lite upload
#!/usr/bin/env perl

use Mojolicious::Lite;

any '/upload' => sub {
my $self = shift;

# Check file size
return $self->render(text => 'File is too big.', status => 200)
if $self->req->is_limit_exceeded;

# Process uploaded file
if (my $example = $self->req->upload('example')) {
my $size = $example->size;
my $name = $example->filename;
$self->render(text => "Thanks for uploading $size byte file $name.");
}
};

app->start;

__DATA__

@@ upload.html.ep
<!DOCTYPE html>
<html>
<head><title>Upload</title></head>
<body>
% my @attrs = (method => 'POST', enctype => 'multipart/form-data');
%= form_for upload => @attrs => begin
%= file_field 'example'
%= submit_button 'Upload'
% end
</body>
</html>
mojo  file  upload  form  example 
21 days ago
« earlier      
acton advice aggregator agile ajax android annoying apache api app article articles audio awesome baby back bank bash bbc blackberry blog bollywood book books browser bug business buy calendar car career cat cats children chrome ci cipr code community computer cool cpan css data database db design dev development diet directory docs documentation download driving drupal editor email emulation exercise family fantastic filter finance firefox fix flash food forum free fun funny game games geek git google government graphics hack hacking hardware harika health help hindi history holiday hosting house household howto html humour ide ideas images india information interesting internet iphone java javascript jenkins job jogi js language laptop law learn learning linux list local london lovefilm mac mailing manual map mapping maps media memory meta methodology microsoft mobile module money movies mp3 music mysql nap network news nostalgia online opensource os osx parenting patterns pda people perl person phone php ping.fm plugin pocketpc politics pr privacy productivity programming python recipe reference research rest retro review reviews ruby scraping screen scrum search security seo shows social socialnetworking socialwork software sql storage stories tech technology test testing text timewaster tips to_do to_read to_watch toddler tool tools torrents travel trump tutorial tv twitter ubuntu uk useful video visa water web web2.0 webdesign website websites wiki wince windows work writing xml xslt youtube zaurus

Copy this bookmark:



description:


tags: