Author: michiel
Date: 2010-03-02 17:05:30 +0100 (Tue, 02 Mar 2010)
New Revision: 41232
Modified:
mmbase/branches/MMBase-1_9/base-webapp/src/main/webapp/mmbase/validation/binaryValid.jspx
mmbase/branches/MMBase-1_9/base-webapp/src/main/webapp/mmbase/validation/validation.js.jsp
Log:
dealing a bit beter if the browser does not property recognize the file
Modified:
mmbase/branches/MMBase-1_9/base-webapp/src/main/webapp/mmbase/validation/binaryValid.jspx
===================================================================
---
mmbase/branches/MMBase-1_9/base-webapp/src/main/webapp/mmbase/validation/binaryValid.jspx
2010-03-02 16:04:27 UTC (rev 41231)
+++
mmbase/branches/MMBase-1_9/base-webapp/src/main/webapp/mmbase/validation/binaryValid.jspx
2010-03-02 16:05:30 UTC (rev 41232)
@@ -28,13 +28,16 @@
if (length == null) {
//probably using the horrible 'browser' from redmond
//MultiPart.MMultipartRequest multipart =
MultiPart.getMultipartRequest((HttpServletRequest) pageContext.getRequest(),
(HttpServletResponse) pageContext.getResponse());
- length = request.getContentLength() - 224/* it's too much, we need to
guess the size of the headers, about 224 */;
+ length = request.getContentLength() - 224/* it's too much, we need to
guess the size of the headers, which would be about 224 */;
}
value = new SerializableInputStream(new NullInputStream(length), length);
if (type.length() > 0) {
- value.setContentType(type);
+ value.setContentType(new MimeType(type));
}
- Collection<LocalizedString> errors = dataType == null ? new
ArrayList<LocalizedString>() : dataType.validate(value, node == null ?
null : new ChangedNode(node, field.getName()), field);
+ Collection<LocalizedString> errors = dataType == null ?
+ new
ArrayList<LocalizedString>() :
+ dataType.validate(value,
+ node ==
null ? null : new ChangedNode(node, field.getName()), field);
pageContext.setAttribute("errors", errors);
pageContext.setAttribute("node", node);
pageContext.setAttribute("field", field);
Modified:
mmbase/branches/MMBase-1_9/base-webapp/src/main/webapp/mmbase/validation/validation.js.jsp
===================================================================
---
mmbase/branches/MMBase-1_9/base-webapp/src/main/webapp/mmbase/validation/validation.js.jsp
2010-03-02 16:04:27 UTC (rev 41231)
+++
mmbase/branches/MMBase-1_9/base-webapp/src/main/webapp/mmbase/validation/validation.js.jsp
2010-03-02 16:05:30 UTC (rev 41232)
@@ -265,6 +265,7 @@
* Returns the mimetype as reported by the browser for the given file
* upload input.
* Probably won't work in IE.
+ * If it can't be determined, this method returns the empty string.
*/
MMBaseValidator.prototype.getMimeType = function(el) {
var type;
@@ -287,14 +288,15 @@
} catch (e) {
// Out of luck, both el.files and the silly activexobject
are not working.
this.showWarning(e);
- type = null;
+ type = "";
}
} else {
// most other browsers simply support the following (Note the
incredible ease and simplicity, compared to the horrible shit of IE).
if (el.files.length > 0) {
type = el.files.item(0).type;
+ //type = "";
} else {
- type = "application/octet-stream";
+ type = "";
}
}
}
@@ -303,6 +305,7 @@
if (value == null) {
type = null;
} else {
+ type = "";
//
}
}
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs