We help IT Professionals succeed at work.

Hoist the colors! We’ve added location flags to usernames sitewide, so it's easier to connect with the global community on EE. View My Profile

x

Malformed multipart POST - Windows Apache (Appserv)

Sailo100
Sailo100 asked
on
2,087 Views
Last Modified: 2013-12-25
Hi All,

Basically i'm trying to install the script at the link below but i keep getting errors.  The script basically just uploads files from your harddrive onto the server while presenting a nice looking progress bar to the user.

http://encodable.com/filechucker/

My Windows Server 2003 is running Appserv 2.57 (PHP, MySQL5, Apache) and i have also installed activeperl!

I can get the script to run, it appears to upload the file into some sort of raw format and then when it gets to the end of the progress bar i get the error :

Software error:
Malformed multipart POST

This is driving me mad, any ideas to get this fixed?

Cheers

Chris
Comment
Watch Question

can you please post the all input and form tags which are belonging to your upload form

Author

Commented:
The form is apart of the cgi script. It is all self contained :

http://encodable.com/filechucker/filechucker.txt
you do not expect that someone debugs your 1000+ lines of code, do you?
Please post the HTML of the form as you get it in your browser. Please post just the form and input tags, no other HTML.

Commented:
It might be helpful to enable debug mode.  In the section PREFs Section 01: Debugging, set $PREF{enable_debug} to 'yes'.  But, it seems to me you're seeing a server error message, not one generated by the script.  What does your apache error log say?

Author

Commented:
The guys who wrote the script seem to think the problem probably lies around the fact that my CGI.pm is version 3 when 3.25 is the newest version.

However i am running Apache on windows x64 which means that nmake is not available.  I have no idea how to do an update to Perl without nmake.

I changed debug to 'yes' and this doesn't seem to do much.  It just shows the same error in the apache error log!

Commented:
From the command line, try:

perl -MCPAN -e 'install CGI'

(see http://search.cpan.org/~jhi/perl-5.8.0/lib/CPAN.pm), or use the Perl Package Manager (ppm) that comes with ActiveState Perl for Windows (see http://aspn.activestate.com/ASPN/docs/ActivePerl-5.6/faq/ActivePerl-faq2.html)

Author

Commented:
I have tried this - > perl -MCPAN -e 'install CGI'

It fails because it tries to run nmake which is only available on 32-bit windows!

How do you use PPM to install / upgrade CGI?
ozo
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2015

Commented:
CGI should have been part of the standard modules installed with Perl.
How did you install perl?
Can you also answer ahoffman's question?

Author

Commented:
CGI was installed with Windows Active Perl but the latest download only includes CGI.pm 3.00 whereby the latest version is 3.25 which i apparently need to try as a potential fix.

<form name="theuploadform" id="theuploadform" method="post" enctype="multipart/form-data" action="upload.cgi" onsubmit="return startupload()">

<div id="intro"><p style="text-align: center;">Upload some files!</p></div>
<div id="setfilecount">Number of files to upload: &nbsp;
<select name="itemcount" id="itemcount">

<option value="1"  selected="selected">1</option>
<option value="2" >2</option>
<option value="3" >3</option>
<option value="4" >4</option>
<option value="5" >5</option>
</select>
 &nbsp; <input type="button" class="defaultbutton" name="updateformfields" value="Apply" onclick="update_form_fields()" />
</div>

<div id="filefields">
      <div class="odd onesubgroup"><div class="fileelement"><label for="uploadname1">File 1 of 1:</label> <input class="file required" type="file" name="uploadname1" id="uploadname1"  /></div></div>
</div>

<input type="hidden" name="numitems" id="numitems" value="1" />
<input type="hidden" name="numfileelements" id="numfileelements" value="1" />
<div id="uploadbuttonwrapper"><input type="button" value="Begin Upload" id="uploadbutton" onclick="startupload()" /></div>
</form>

Commented:
>> It fails because it tries to run nmake which is only available on 32-bit windows!

I'm not sure that's true.  Have a look at the various Software Developer Kits from MS -- I'm pretty sure one or more (.NET, Visual C++, Win2003 Server) of them include a 64-bit compiler.  More info:

http://msdn.microsoft.com/vstudio/express/default.aspx

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/kernel_d/hh/kernel_d/64bitAMD_1f7a33fb-6c2c-416c-9ac7-5e9324026364.xml.asp

http://www.microsoft.com/downloads/details.aspx?FamilyId=484269E2-3B89-47E3-8EB7-1F2BE6D7123A&displaylang=en
Top Expert 2006

Commented:
use ppm to install modules with activestate. it's covered in the activestate help files or you can look it up  on their website. Basically:

c:\> ppm

then

c:\> install CGI


 

Author

Commented:
mjocyne - all of that  compilers and stuff are a bit over my head really!

i tried ppm - and the gui cannot load on 64-bit windows.

so i tried ppm install CGI and it says CGI is installed.

so i did ppm upgrade CGI and it said there are no updates.

i'm lost now.

Commented:
Okay, I think this error's coming from Apache anyway, so let's get back to the error itself for a bit...

Does this happen with all files you attempt to upload?  Say you tried to upload a small binary file under 1 MB -- does this trip the error?  How about a small text file?

Are there no entries written to Apache's error log other than this one?  Nothing about "Premature end of script headers" or any such?

Author

Commented:
The error appears to happen on all file sizes.

Interestingly when i try the script today I am getting the following error :

upload.cgi: CGI.pm: Server closed socket during multipart read (client aborted?).,

There are no "Premature end of script headers" in the log file.

Commented:
Well, one thing to try is to uninstall the 64-bit ActiveState Perl, and then install the 32-bit version.  Upgrade CGI.pm via the PPM program, and see if that solves the problem.  If it doesn't, we're dealing with something other than a CGI.pm issue...
Top Expert 2006

Commented:
this is in the CGI.pm module source code:

    # An apparent bug in the Apache server causes the read()
    # to return zero bytes repeatedly without blocking if the
    # remote user aborts during a file transfer.  I don't know how
    # they manage this, but the workaround is to abort if we get
    # more than SPIN_LOOP_MAX consecutive zero reads.
    if ($bytesRead == 0) {
      die  "CGI.pm: Server closed socket during multipart read (client aborted?).\n"
          if ($self->{ZERO_LOOP_COUNTER}++ >= $SPIN_LOOP_MAX);
    } else {
      $self->{ZERO_LOOP_COUNTER}=0;
    }

also in the source code:

$SPIN_LOOP_MAX = 2000;  # bug fix for some Netscape servers

apparently you're running into the 2000 loop limit, but for what reason?
your form calls the javascript function startupload() twice. Is this what you really want?

Author

Commented:
I fixed this by downloading the CPAN CGI Module and manually copying the files over the files in C:\Perl\Site\Lib.

The script vendor was correct except i was told to update the files in C:\Perl\Lib and this did not work.

Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.