Skip to content

Instantly share code, notes, and snippets.

@soh335
Created October 4, 2010 08:44
Show Gist options
  • Save soh335/609400 to your computer and use it in GitHub Desktop.
Save soh335/609400 to your computer and use it in GitHub Desktop.
use strict;
use warnings;
use Plack::Request;
use Data::Dumper;
use Path::Class qw/file/;
use File::Copy;
use Cwd;
return sub {
my $env = shift;
my $req = Plack::Request->new( $env );
my $file = $req->uploads->{image};
if ($file) {
my $tempfile = Path::Class::File->new($file->{tempname});
my $movepath = File::Spec->catfile(getcwd, 'tmp',$file->{filename});
File::Copy::move($tempfile->stringify, $movepath);
}
return [
200,
['Content-Type' => 'text/plain'],
['OK'],
];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment