Created
November 26, 2017 03:42
-
-
Save anonymous/8107c16078ad5c551236f11f1159d621 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# html | |
<div> | |
<form action="/files_upload" method="post" enctype="multipart/form-data"> | |
<div class="section3"> | |
<br> | |
<input type="submit" class="button" value="<%= translate 'upload_file_button' %>"> | |
<label for="file_upload" class="button"> | |
<input id="file_upload" type="file" name="file" multiple> | |
</label> | |
</div> | |
</form> | |
</div> | |
# Route | |
$logged_in->post('/files_upload')->to('files#upload'); | |
# Controller code | |
sub upload { | |
my $self = shift; | |
my $dir = $self->param("dir"); | |
my $file_dir = $self->param("file_dir"); | |
my $back = url_escape( $self->param("back") ); | |
my $xpath = $self->param("xpath"); | |
my $select_files = $self->param("select_files"); | |
my $filter = $self->param("filter"); | |
$self->render( text => "Request too big", status => 200 ) | |
if $self->req->is_limit_exceeded; | |
for my $file ( @{$self->every_param("file")} ) { | |
# skip if filename is empty or filename does not match with filter | |
next if $file->filename =~ /^ *$/; | |
next if $file->filename !~ /$filter/; | |
my $dest_path = $file_dir . "/" . $file->filename; | |
$file->move_to( $dest_path ); | |
} | |
$self->redirect_to("*****hidden*****"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment