This should be a simple one. I am using CGI.pm to upload files to the server and all works for the JPGs. However, for some reason, the equivalent code for PDFs fails. My apache error log gives a "Malformed multipart POST: data truncated" and I have seen this cited elsewhere. Again, the same thing works for the image files in parallel code.
The form is simple:
<form enctype="multipart/form-data" method="post" action="xxxxx"> <input type="file" accept="application/pdf" name="file"> <input type="submit" value="Upload"> </form>
(xxxxx is just hiding the actual script name.)
For jpgs, I have this, and it works:
<form enctype="multipart/form-data" method="post" action="yyyyy"> <input type="file" accept="image/jpg" name="file"> <input type="submit" value="Upload"> </form>
It is processed with:
my $cgi = new CGI; my $file = new $cgi->param('file'); open(FUP,">$vdir$fn"); while (<$file>) { print FUP $_; } close FUP; print $cgi->header();
The only real difference for the JPG uploader for that is that there is a size restriction placed on the file with:
$CGI::POST_MAX = 1024 * 1024;
I do not have that at all for the PDFs. Is "application/pdf" incorrect or do I have to make some other accommodation? This has to be a SMH simple thing, but eludes me.
Thanks, in advance, for any assistance.
One thing that did occur to me is the possibility of a buffer limitation in the post. I have bumped up against that for $ENV{'CONTENT_LENGTH'} before.
UPDATE - SOLVED
I'll keep this here with the solution in case someone else faces the same thing.
sysread(STDIN, $inputdata, $ENV{'CONTENT_LENGTH'});
Don't need to do this, unlike in ordinary form post processing. Leave that out and it works like a charm.
In reply to File Upload Frustration by jcinsd
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |