Link to home
Create AccountLog in
Avatar of aumanpj
aumanpj

asked on

Problem accessing uploaded .docx files on IIS server.

I am running Windows Server 2003 with IIS and I have an .asp scripted form that website users fill fill out and submit. The form has been in use for many years and it includes a file upload feature that had always been limited to .doc files. Recently, I modified the script to allow for .pdf and .docx file types

All works well with the file upload; however, when I attempt to access the uploaded .docx files, I get an error message that says the file cannot be opened because of problems with its contents. Upon clicking Ok, I am then presented a message that asks whether or not I want to recover its contents - which I do and then am able to view its contents. Upon recovery, all uploaded files are intact.

Is is it possible to achieve the .docx file upload without the file users experiencing the recovery process? I've been reading into this a bit and I've begun thinking it may have to do with MIME settings. I need someone who can walk me through a solution to this problem.

Thank you.  I look forward to hearing from you.
Avatar of Giladn
Giladn
Flag of Israel image

I think you are on the right track, this is for PDF files :
http://stackoverflow.com/questions/312230/proper-mime-type-for-pdf-files

about DOCX i'm not sure , look here:
http://forums.iis.net/t/1174874.aspx


hope this helps,

G
Avatar of aumanpj
aumanpj

ASKER

Hello Giladn,

To clarify, I am having no problems with the .pdf files. Also, thank  you for the link about .docx. So far, I have determined that my server has no applicationHost.config file. Also, I am a bit surprised to read on this page: http://blogs.technet.com/b/office_resource_kit/archive/2009/06/30/register-office-2007-file-format-mime-types-on-servers.aspx that MIME types are automatically registered with computers running Windows Server 2003 Service Pack 2 (SP2) or later versions. My Windows Server 2003 has Service Pack 2.

Hmm... I will continue reading through the thread, but I thought I'd post this update in the mean-time.
Hi,

when opening .doc files do they open in a new windows or the same frame/window ?
try opening the pdf files in the same windows or remove _blank from the open command see if this helps..
ASKER CERTIFIED SOLUTION
Avatar of aumanpj
aumanpj

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of aumanpj

ASKER

Update: I tried changing the MIME format to application/msword as suggested by this thread:


http://www.aspmessageboard.com/showthread.php?230778-Downloaded-.docx-files-are-corrupted


and there was no change in behavior. I have the same error. The .docx file upload results in a corrupted file that must be restored regardless of whether there is a mime setting or not and regardless of either mime setting value.

Besides setting the mime, is there anything that I have to install related to the mime setting? I've read nothing about having to do that.

Any other ideas about what could be going wrong here? Could the upload process be corrupting the file some how and only so for .docx files?
Avatar of aumanpj

ASKER

Another update:

I have run test after test after test in search of some common denominators and the more tests I conduct, the more confused I become!

At this moment, I have the MIME set to application/vnd.openxmlformats-officedocument.wordprocessingml.document.

Some .docx files upload correctly and without any corruption, but some do not! I cannot explain why some work and some do not. Does anyone here have a hypothesis for that?
Avatar of aumanpj

ASKER

Any other input on this????
Avatar of aumanpj

ASKER

I am still without a solution on this and would love to hear from anyone else who has any other insights.

I have been reading as much as possible and I have begun to wonder if the file upload routine's process of changing the file name somehow corrupt's the .docx file's table of contents - thus requiring a restoration of the file before it can be opened.

Does this ring a bell for anyone? If so, can my file upload routine change the name of the file in some alternative way and that avoids corruption of the table of contents? I am very eager to solve this problem. Thank you very much for considering this.
Avatar of aumanpj

ASKER

Thank you Giladn for your input.  I ended up paying $700 to edit the upload script. This was not a MIME problem. Yes, I overpaid but I needed this to get done ASAP and my existing knowledge and message board queries were not successful. For your information, the programmer who fixed this said the following:

At one point the form converted the uploaded file from binary data to a binary array and then stored it to the stream object. There was an issue which caused it to have an extra byte. A different method has been used to retrieve the data and the file size is now controlled so there is no extra byte. Before, when the recordset field was appending the binary array to the recordset field, it was using the appendChunk method. That way the form was retrieving the data by getting it's value back, which has no control over it's size. But now the form uses a method called getchunk which can control the size it is retrieving. I put the size of the binary data minus one into the parameter.

Hopefully this information might help the next person with this problem.