I have a form that uses enctype="multipart/form-data" in a production server
with Coldfusion MX 7 that's working fine. But when I try to move the
application to the Coldfusion 8 it crashes!
This error only happens when using GetPageContext().forward() after submiting
the form. We need to use forward method after the submitting (instead of using
the <cflocation>) because we want to keep the status of the page.
The exception we get is the following one:
[b]Corrupt form data: premature ending[/b]
[i]
The error occurred in D:\Inetpub\wwwroot\LRNSystemMVC\test.cfm: line 3
1 : <cfif isDefined('form.submit')>
2 : <cfscript>
3 : GetPageContext().forward('index.cfm');
4 : </cfscript>
5 : </cfif>
This is the stacktrace of the error:
java.io.IOException: Corrupt form data: premature ending
at
com.oreilly.servlet.multipart.MultipartParser.<init>(MultipartParser.java:169)
at
com.oreilly.servlet.multipart.MultipartParser.<init>(MultipartParser.java:93)
at coldfusion.filter.FormScope.fillMultipart(FormScope.java:136)
at
coldfusion.filter.FusionContext.SymTab_initForRequest(FusionContext.java:428)
(continues...)
[/i]
You can reproduce the error with the attached code.
Thanks in advance,
Maiquel
[b]form.cfm[/b]
<cfif isDefined('form.submit')>
<cfscript>
GetPageContext().forward('index.cfm');
</cfscript>
</cfif>
<form action="test.cfm" name="form1" method="post"
enctype="multipart/form-data">
<input type="file">
<input type="submit" name="submit" id="submit">
</form>
Maiquel
Although this bug has already been submitted as 71432. You can watch for the
next cf8 cumulative hot fix to see if it is resolved there or in cf8.01 (in
beta). I will try to post if I see it is fixed.
You set the jvm argument as -Dcoldfusion.markResetForMultiPart=false
or programatically set it as:
<cfscript>
sys = createObject("java","java.lang.System");
sys.setProperty("coldfusion.markResetForMultiPart", "false");
</cfscript>
It is better to set it as a JVM argument since the script does impact the
whole CF server. There will be some loss of performance for fileupload. It will
remain similar to cfmx7 performance with this property set false.
I tried both solutions but the problem persists.
I found a post in the "Coldfused?" blog about the new upload code in CF8:
http://coldfused.blogspot.com/2007/08/coldfusion-8-changes-with-file-upload.html
There, the solution proprosed to use the old upload code from CF mx7 is to set
the argument markResetForMultiPart to true:
-Dcoldfusion.markResetForMultiPart=true
I would like to remind you that we use the enctype=?multipart/form-data? in
the form, however uploading or not a file we get this exception. I don?t thinl
our problem is related with the size of the file.
Do you know any other workaround for this problem?
Thank you in advance,
Maiquel Sampaio
I did some tests with the code above and with another one more complex and
none problem occurred.
I think this bug can be marked as resolved.
Regards,
Maiquel Sampaio de Melo
The Coldfusion 8 has not fixed the problem.
You gotta do a combination of things to get this problem solved.
Indeed you need to have the version 8.0.1 running, but it must be running on
the JRE 1.5.0.15 and you must also set in the JVM the argument
-Dcoldfusion.markResetForMultiPart=true (not false as mentioned above).
It was a nightmare to figure out all this, I hope adobe get this fixed in the
next hot fixes. This is nothing something easy to get it fix, and can drive a
man mad!
I hope no one besides us have faced this problem!
Best regards...
JC