Trying some things
This commit is contained in:
parent
f9a99b1b85
commit
1b62fda8d0
|
@ -51,13 +51,18 @@ get '/', -> $request, $response {
|
|||
};
|
||||
|
||||
post '/', -> $request, $response {
|
||||
my Str $filename =
|
||||
$request.content<file><filename> ~
|
||||
'.' ~
|
||||
$request.content<file><headers><content-type>.split('/')[1];
|
||||
my Buf $file-body = $request.content<file><body>;
|
||||
# This works:
|
||||
#my Str $filename =
|
||||
# $request.content<file><filename> ~
|
||||
# '.' ~
|
||||
# $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('/');
|
||||
};
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
<body>
|
||||
<h1>{{title}}</h1>
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
<div>
|
||||
<label for="author">Author</label>
|
||||
<input type="text" name="author" id="author">
|
||||
</div>
|
||||
<div>
|
||||
<label for="file-upload">File</label>
|
||||
<input type="file" name="file-upload" id="file-upload"
|
||||
|
|
Loading…
Reference in a new issue