Fórum
Form enctype="multipart/form-data" + captcha
Bea Bravo, modificado 12 Anos atrás.
Form enctype="multipart/form-data" + captcha
New Member Postagens: 5 Data de Entrada: 29/09/10 Postagens Recentes
Hello,
I'm use Liferay 6.0 and I'm programming a portlet who contains one form. This form has the enctype "multipart/form-data"" because has a field for upload a file. This form use the captcha of Liferay also. The form works succesfully when it has not captcha.
<form:form name="formStep1" commandName="solicitud" method="post" action="${formStep2ActionUrl}" enctype="multipart/form-data">
<form:input type="text" path="nombre" name="nombre" id="nombre"/>
....
<form:input id="file" name="file" type="file" path="file" />
...
</form:form>
But when I add the code corresponding of catcha, the portlet fails (Text verification failed.):
<form:form name="formStep1" commandName="solicitud" method="post" action="${formStep2ActionUrl}" enctype="multipart/form-data">
<form:input type="text" path="nombre" name="nombre" id="nombre"/>
....
<form:input id="file" name="file" type="file" path="file" />
....
<liferay-ui:captcha url="<%= captchaURL %>" />
...
</form:form>
If I put enctype="multipart/form-data" the upload file works fine but the catpcha no. If I don't put enctype="multipart/form-data", the captcha works fine but the upload file no. Anybody can help me, please? How can I resolve this?
Thank you.
Bea.
I'm use Liferay 6.0 and I'm programming a portlet who contains one form. This form has the enctype "multipart/form-data"" because has a field for upload a file. This form use the captcha of Liferay also. The form works succesfully when it has not captcha.
<form:form name="formStep1" commandName="solicitud" method="post" action="${formStep2ActionUrl}" enctype="multipart/form-data">
<form:input type="text" path="nombre" name="nombre" id="nombre"/>
....
<form:input id="file" name="file" type="file" path="file" />
...
</form:form>
But when I add the code corresponding of catcha, the portlet fails (Text verification failed.):
<form:form name="formStep1" commandName="solicitud" method="post" action="${formStep2ActionUrl}" enctype="multipart/form-data">
<form:input type="text" path="nombre" name="nombre" id="nombre"/>
....
<form:input id="file" name="file" type="file" path="file" />
....
<liferay-ui:captcha url="<%= captchaURL %>" />
...
</form:form>
If I put enctype="multipart/form-data" the upload file works fine but the catpcha no. If I don't put enctype="multipart/form-data", the captcha works fine but the upload file no. Anybody can help me, please? How can I resolve this?
Thank you.
Bea.
Asier Hernández, modificado 12 Anos atrás.
RE: Form enctype="multipart/form-data" + captcha
New Member Postagens: 24 Data de Entrada: 01/02/11 Postagens Recentes
Have you found any solution to this isuue??
I have the same problem with captcha and multipart/form data.
Thanks in advance
I have the same problem with captcha and multipart/form data.
Thanks in advance
Miguel Ángel Júlvez, modificado 11 Anos atrás.
RE: Form enctype="multipart/form-data" + captcha
Junior Member Postagens: 63 Data de Entrada: 29/03/11 Postagens Recentes
Any update about this issue?
Regards!
Regards!
Asier Hernández, modificado 11 Anos atrás.
RE: Form enctype="multipart/form-data" + captcha
New Member Postagens: 24 Data de Entrada: 01/02/11 Postagens Recentes
Yes, here is how I have resolved this issue:
I hope this will help you.
<c:if test="<%= requireCaptcha %>">
<portlet:resourceurl var="captchaURL">
<portlet:param name="<%= Constants.CMD %>" value="captcha" />
</portlet:resourceurl>
<liferay-ui:captcha url="<%= captchaURL %>" />
</c:if>
I hope this will help you.
Miguel Ángel Júlvez, modificado 11 Anos atrás.
RE: Form enctype="multipart/form-data" + captcha
Junior Member Postagens: 63 Data de Entrada: 29/03/11 Postagens Recentes
Thanks Asier but I've that piece of code and it doesn't work
This is the error line in catalina.out
ERROR [SimpleCaptchaImpl:398] Captcha text is null. User null may be trying to circumvent the captcha.
It happens when I send a multipart form with captcha
Regards!
This is the error line in catalina.out
ERROR [SimpleCaptchaImpl:398] Captcha text is null. User null may be trying to circumvent the captcha.
It happens when I send a multipart form with captcha
Regards!
Asier Hernández, modificado 11 Anos atrás.
RE: Form enctype="multipart/form-data" + captcha
New Member Postagens: 24 Data de Entrada: 01/02/11 Postagens Recentes
I think youl will have to change the code in your Portlet class. In my code I have my WebFormPortlet.java with this code in the saveData method:
And this would be my serveResource method:
Try if this is a valid solution for your problem.
if (requireCaptcha) {
try {
//CaptchaUtil.check(actionRequest);
String enteredCaptchaText = ParamUtil.getString(uploadRequest, "captchaText");
PortletSession session = actionRequest.getPortletSession();
//String captchaText = getCaptchaValueFromSession(session);
String captchaText = "";
Enumeration<string> atNames = session.getAttributeNames();
while (atNames.hasMoreElements()) {
String name = atNames.nextElement();
if (name.contains("CAPTCHA_TEXT")) {
captchaText = (String) session.getAttribute(name);
}
}
if (Validator.isNull(captchaText)) {
throw new Exception("Internal Error! Captcha text not found in session");
}
if (!StringUtils.equals(captchaText, enteredCaptchaText)) {
throw new Exception("Invalid captcha text. Please reenter.");
}
}
catch (CaptchaTextException cte) {
SessionErrors.add(
actionRequest, CaptchaTextException.class.getName());
return;
}
}
</string>
And this would be my serveResource method:
public void serveResource(
ResourceRequest resourceRequest, ResourceResponse resourceResponse)
throws IOException, PortletException {
String cmd = ParamUtil.getString(resourceRequest, Constants.CMD);
try {
if (cmd.equals("captcha")) {
//serveCaptcha(resourceRequest, resourceResponse);
com.liferay.portal.kernel.captcha.CaptchaUtil.serveImage(resourceRequest, resourceResponse);
}
else if (cmd.equals("export")) {
exportData(resourceRequest, resourceResponse);
}
}
catch (Exception e) {
_log.error(e, e);
}
}
Try if this is a valid solution for your problem.
Miguel Ángel Júlvez, modificado 11 Anos atrás.
RE: Form enctype="multipart/form-data" + captcha
Junior Member Postagens: 63 Data de Entrada: 29/03/11 Postagens Recentes
It works!!!
Thanks Asier!
Thanks Asier!
Jose Jimenez, modificado 9 Anos atrás.