Link to home
Start Free TrialLog in
Avatar of Sailo100
Sailo100

asked on

Malformed multipart POST - Windows Apache (Appserv)

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
Avatar of ahoffmann
ahoffmann
Flag of Germany image

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

ASKER

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.
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?
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!
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)
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?
Avatar of ozo
CGI should have been part of the standard modules installed with Perl.
How did you install perl?
Can you also answer ahoffman's question?
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>
>> 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
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


 
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.
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?
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.
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...
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?
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.

ASKER CERTIFIED SOLUTION
Avatar of AnnieMod
AnnieMod
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial