my $q=$params{cgi};
if (defined $form->field("do") && $form->field("do") eq "edit") {
+ # Add attachment field, set type to multipart.
+ $form->enctype(&CGI::MULTIPART);
$form->field(name => 'attachment', type => 'file');
# These buttons are not put in the usual place, so
# are not added to the normal formbuilder button list.
# of the temp file that CGI writes the upload to.
my $tempfile=$q->tmpFileName($filename);
+ if (! defined $tempfile || ! length $tempfile) {
+ error("failed to determine tempfile name");
+ }
+
$filename=IkiWiki::titlepage(
IkiWiki::possibly_foolish_untaint(
attachment_location($form->field('page')).
# needed by old CGI versions
$fh=$q->param('attachment');
if (! defined $fh || ! ref $fh) {
- error("failed to get filehandle");
+ # even that doesn't always work,
+ # fall back to opening the tempfile
+ $fh=undef;
+ open($fh, "<", $tempfile) || error("failed to open $tempfile: $!");
}
}
binmode($fh);