-sub match_minsize ($$;@) { #{{{
- shift;
- my $minsize=eval{parsesize(shift)};
- if ($@) {
- return IkiWiki::FailReason->new("unable to parse minsize (or number too large)");
+ json_response($q, $form, $dest."/".$filename, stored_msg());
+}
+
+# Save all stored attachments for a page.
+sub attachments_save {
+ my $form=shift;
+ my $session=shift;
+
+ # Move attachments out of holding directory.
+ my @attachments;
+ my $dir=attachment_holding_location($form->field('page'));
+ foreach my $filename (glob("$dir/*")) {
+ $filename=Encode::decode_utf8($filename);
+ next unless -f $filename;
+ my $destdir=$config{srcdir}."/".
+ linkpage(IkiWiki::possibly_foolish_untaint(
+ attachment_location($form->field('page'))));
+ my $destfile=IkiWiki::basename($filename);
+ my $dest=$destdir.$destfile;
+ unlink($dest);
+ IkiWiki::prep_writefile($destfile, $destdir);
+ rename($filename, $dest);
+ push @attachments, $dest;