How do I filter for Docx files for upload

mbart
mbart used Ask the Experts™
on
I have an uploader control and I filter for mime types using below statement
problem is when I try to upload docx files.  Returns invaliid file type.
           
if (StatementUpload.PostedFile.ContentType.Equals("application/msword") || StatementUpload.PostedFile.ContentType.Equals("application/pdf") || StatementUpload.PostedFile.ContentType.Equals("text/plain"))

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
According to this :

http://www.wrensoft.com/forum/showthread.php?t=2834

You should try x-zip-compressed or another format listed.

Author

Commented:
How do I do that?  As the code snippet shows, I am trying to upload the file and hopefully later download it.  How do I compress it in the interim as you suggest?

Author

Commented:
When I used the mime type listed in your reference I get the following error:
Database Error Updating memberString or binary data would be truncated. The statement has been terminated.
File type on the database is set to image and the file I attempted to upload is a rather small file 68KB
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

Author

Commented:
Tried changing the datatype on the db server to varbinary(MAX) and got the same error.

Commented:
I didnt suggest to compress it, I mean docx files are zipped xml, and should seem like "x-zip-compressed" for the server.

Did you try to add "x-zip-compressed" to the content-type accept list ? If yes, what did happen ?

Author

Commented:
I will give it a try.  Standby

Author

Commented:
I tried it as
EndorsementUpload.PostedFile.ContentType.Equals("x-zip-compressed") and got invalid file type error.

Commented:
did you try thi one ? :

"application/vnd.openxmlformats-officedocument.wordprocessingml.document"

Author

Commented:
As stated earlier, tried that already with the following error.

Database Error Updating memberString or binary data would be truncated. The statement has been terminated.  

Commented:
What is the definition of this field in your database ? varchar ? ..

Author

Commented:
image, also tried varbinary(MAX) but no joy

Author

Commented:
Would it be possible to use the file extension instead?  If so can you provide a sample of the script?
 
 

Author

Commented:
Thanks for the patience!  Found what was causing the error.  Length of the MIME type field in the db was causing the issue.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial