From ba70330b700ff54eb750e4f26b6720f78a67e8a9 Mon Sep 17 00:00:00 2001 From: swaggboi Date: Fri, 10 Nov 2023 00:25:28 -0500 Subject: [PATCH] Save uploaded file to uploads dir --- multipart-form/multipart-form.raku | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/multipart-form/multipart-form.raku b/multipart-form/multipart-form.raku index f967d5d..bb920c1 100755 --- a/multipart-form/multipart-form.raku +++ b/multipart-form/multipart-form.raku @@ -51,7 +51,13 @@ get '/', -> $request, $response { }; post '/', -> $request, $response { - dd $request.content; + my Str $filename = + $request.content ~ + '.' ~ + $request.content.split('/')[1]; + my Buf $file-body = $request.content; + + ('uploads/' ~ $filename).IO.spurt: $file-body; $response.redirect('/'); };