Trying some things

This commit is contained in:
swagg boi 2023-11-10 01:33:40 -05:00
parent f9a99b1b85
commit 1b62fda8d0
2 changed files with 15 additions and 6 deletions

View file

@ -51,13 +51,18 @@ get '/', -> $request, $response {
}; };
post '/', -> $request, $response { post '/', -> $request, $response {
my Str $filename = # This works:
$request.content<file><filename> ~ #my Str $filename =
'.' ~ # $request.content<file><filename> ~
$request.content<file><headers><content-type>.split('/')[1]; # '.' ~
my Buf $file-body = $request.content<file><body>; # $request.content<file><headers><content-type>.split('/')[1];
#my Buf $file-body = $request.content<file><body>;
#
#('uploads/' ~ $filename).IO.spurt: $file-body;
('uploads/' ~ $filename).IO.spurt: $file-body; # Not sure about this:
dd $request.content<author><body>.decode; # Works!
dd $request.content<file-upload>; # Doesn't like hyphen?
$response.redirect('/'); $response.redirect('/');
}; };

View file

@ -6,6 +6,10 @@
<body> <body>
<h1>{{title}}</h1> <h1>{{title}}</h1>
<form method="post" enctype="multipart/form-data"> <form method="post" enctype="multipart/form-data">
<div>
<label for="author">Author</label>
<input type="text" name="author" id="author">
</div>
<div> <div>
<label for="file-upload">File</label> <label for="file-upload">File</label>
<input type="file" name="file-upload" id="file-upload" <input type="file" name="file-upload" id="file-upload"