X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/6ebb4e262ef70ec85436b7f0bff134009ce08f3b..506d16a8a01e563601dee2ddde877cb8210a61ef:/IkiWiki/Plugin/attachment.pm?ds=inline diff --git a/IkiWiki/Plugin/attachment.pm b/IkiWiki/Plugin/attachment.pm index 490014a7e..4d6dee23e 100644 --- a/IkiWiki/Plugin/attachment.pm +++ b/IkiWiki/Plugin/attachment.pm @@ -228,7 +228,7 @@ sub attachment_store { check_canattach($session, $final_filename, $tempfile); }; if ($@) { - json_response($q, $dest."/".$filename, $@); + json_response($q, $form, $dest."/".$filename, $@); error $@; } @@ -259,7 +259,7 @@ sub attachment_store { }); } - json_response($q, $dest."/".$filename, stored_msg()); + json_response($q, $form, $dest."/".$filename, stored_msg()); } # Save all stored attachments for a page. @@ -360,17 +360,17 @@ sub stored_msg { gettext("just uploaded"); } -sub json_response ($$$) { +sub json_response ($$$$) { my $q=shift; + my $form=shift; my $filename=shift; my $stored_msg=shift; - # for the jquery file upload widget - if ($q->Accept("application/json") >= 1.0 && - grep { /application\/json/i } $q->Accept) { + if (! defined $form->submitted || + $form->submitted ne "Upload Attachment") { eval q{use JSON}; error $@ if $@; - print "Content-type: application/json\n\n"; + print "Content-type: text/html\n\n"; my $size=-s $filename; print to_json([ {