S
Stephen Riek
I'm uploading a file via servlets or JSP, using the O'Reilly
MultipartWrapper, and was hoping that to be able to determine the file
type (eg. Excel spreadsheet, Word document, Powerpoint, PDF) depending
on the Mime Type.
Simple enough using the O'Reilly servlet package ~
<%@ page import="com.oreilly.servlet.*" %>
<%
if (request instanceof MultipartWrapper) {
try {
// Cast the request to a MultipartWrapper
MultipartWrapper multi = (MultipartWrapper)request;
// The file upload field on the submitting form is called
'upfile'.
String mimeType = multi.getContentType("resourcefile");
...
%>
Strange thing though is that I'm not getting the expected Mime Type.
For example, I just uploaded a Microsoft Word document and the
mimeType String is "application/octet-stream" instead of the expected
"application/msword".
However, uploading Excel spreadsheets and PDF files provided the
expected results of "application/vnd.ms-excel" and "application/pdf".
(see http://www.bc.edu/bc_org/tvp/email/helpers.shtml or
http://www.yolinux.com/TUTORIALS/LinuxTutorialMimeTypesAndApplications.html
for lists of mime types)
So, does anybody know why the Microsoft Word documents send the wrong
mime type ? Should I instead just use the file extension to determine
file type perhaps ?
Thanks in advance,
Stephen
MultipartWrapper, and was hoping that to be able to determine the file
type (eg. Excel spreadsheet, Word document, Powerpoint, PDF) depending
on the Mime Type.
Simple enough using the O'Reilly servlet package ~
<%@ page import="com.oreilly.servlet.*" %>
<%
if (request instanceof MultipartWrapper) {
try {
// Cast the request to a MultipartWrapper
MultipartWrapper multi = (MultipartWrapper)request;
// The file upload field on the submitting form is called
'upfile'.
String mimeType = multi.getContentType("resourcefile");
...
%>
Strange thing though is that I'm not getting the expected Mime Type.
For example, I just uploaded a Microsoft Word document and the
mimeType String is "application/octet-stream" instead of the expected
"application/msword".
However, uploading Excel spreadsheets and PDF files provided the
expected results of "application/vnd.ms-excel" and "application/pdf".
(see http://www.bc.edu/bc_org/tvp/email/helpers.shtml or
http://www.yolinux.com/TUTORIALS/LinuxTutorialMimeTypesAndApplications.html
for lists of mime types)
So, does anybody know why the Microsoft Word documents send the wrong
mime type ? Should I instead just use the file extension to determine
file type perhaps ?
Thanks in advance,
Stephen