Link to home
Start Free TrialLog in
Avatar of mbart
mbart

asked on

How do I filter for Docx files for upload

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

ASKER CERTIFIED SOLUTION
Avatar of flob9
flob9
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mbart
mbart

ASKER

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?
Avatar of mbart

ASKER

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
Avatar of mbart

ASKER

Tried changing the datatype on the db server to varbinary(MAX) and got the same error.
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 ?
Avatar of mbart

ASKER

I will give it a try.  Standby
Avatar of mbart

ASKER

I tried it as
EndorsementUpload.PostedFile.ContentType.Equals("x-zip-compressed") and got invalid file type error.
did you try thi one ? :

"application/vnd.openxmlformats-officedocument.wordprocessingml.document"
Avatar of mbart

ASKER

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.  
What is the definition of this field in your database ? varchar ? ..
Avatar of mbart

ASKER

image, also tried varbinary(MAX) but no joy
Avatar of mbart

ASKER

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

ASKER

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