2

When loading the below script I get AH01215: Malformed multipart POST: data truncated error in Apache error log.

I need to pass files through AJAX, so I use FormData (in the below script for simplicity there are no file fields).

What is the error?

#!/usr/bin/perl

use strict;
use warnings;

use CGI qw/:standard/;

if(param('ajax')) {
  print header('text/plain');
  print "YY";
  exit;
}

print header('text/html');
print q~
<html>
<head>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
  <script>
  $.ajax({
    url: '', 
    type: 'POST',
    data: new FormData($('#form')[0]),
    processData: false,
    contentType: false // Using FormData, no need to process data.
  }).done(function(data){
    alert(data);
  });
  </script>
</head>
<body>

<form id="#form" enctype="multipart/form-data">
<input type="hidden" name="ajax" value="1"/>
</form>

</body>
</html>
~;

Note that upgrading jQuery to a newer version seems NOT to solve the problem.

porton
  • 4,482
  • 7
  • 32
  • 66

0 Answers0