]> git.plutz.net Git - shellwiki/commitdiff
basic attachment upload
authorPaul Hänsch <paul@plutz.net>
Fri, 15 Apr 2022 12:30:02 +0000 (14:30 +0200)
committerPaul Hänsch <paul@plutz.net>
Fri, 15 Apr 2022 12:30:02 +0000 (14:30 +0200)
attachment.sh

index d004b0db549954f00575810169f6a6665c9357e3..9b5d54590258c55d0115155ceb6dadf0dd60d908 100755 (executable)
@@ -63,8 +63,13 @@ attachment_convert(){
 if [ "${PATH_INFO%/\[attachment\]/}"  != "${PATH_INFO}" ]; then
   . "$_EXEC/multipart.sh"
   if multipart_cache; then
-    debug 'Multipart "file":'
-    multipart file |hd |debug >/dev/null
+    mkdir -p "$_DATA/pages/${PATH_INFO%/\[attachment\]/}/#attachments/"
+    n=1; while filename=$(multipart_filename "file" "$n"); do
+      filename="$(printf %s "$filename" |tr /\\0 __)"
+      multipart "file" "$n" >"$_DATA/pages/${PATH_INFO%/\[attachment\]/}/#attachments/$filename"
+      n=$((n + 1))
+    done
+    rm -- "$multipart_cachefile"
     REDIRECT "${_BASE}${PATH_INFO}"
   else
     theme_attachments "${PATH_INFO%\[attachment\]/}"