[dancer-users] Image Uploader

Russell Jenkins russell.jenkins at strategicdata.com.au
Sat Sep 5 23:46:22 BST 2015


On 6/09/2015 7:54 am, Richard Reina wrote:
> post '/upload' => sub {
>     my $file = request->upload('file');
>         my $fname = $file->filename;
>         my $tmpname = $file->tempname;
>         my $destination = $upload_dir . '/' . $fname;
>         $file->copy_to($destination);
>         unlink $tmpname if -e $tmpname;
>
>     print "Done\n";
> };
>

Note that `print` returns true if successful.

The `print` statement is the last one in your route, and the returned 
value from a route becomes the response content.

Hope that helps,
   Russell.




More information about the dancer-users mailing list