I have a section of my site that allows users to upload and download files.
For security issues, We use a com object to take the file as a binary stream and store it on our network off of the web server (under a different randomly generated file name).
The same com object is used to stream the file back to the user if they open the link to it so they never know where the actual file is stored.
Everything was fine with this until we upgraded to Office 2010 now docx and xlsx files are uploading fine but when they are opened via the web site, a dialog appears telling the user the file has unreadible content and asking if they wish to recover the document.
After saying yes to this the file opens perfectly. Other files .doc .xls .csv .txt etc are all unaffected.
I can open the files directly from the network folder with no issue so I think it is where I am streaming it back to the users browser that is the issue (I'm using VB.net):
sub OpenFile(byref FilePath as string, byref FileName as string) dim objDocument As Object = CreateObject("DocumentHandler") dim DocStream() as Byte If objDocument.CheckDocumentExists(FilePath) then 'fetch document from network as a byte array DocStream = objDocument.FetchDocument(Server.UrlDecode(FilePath)) 'open stream in new container by file name Response.Clear() Response.ClearHeaders() Response.AppendHeader("Content-Disposition", "Attachment; Filename=" & FileName) 'Write the file directly to the HTTP output stream... Response.BinaryWrite(DocStream) Response.End() end if end sub
If anybody has any idea what is wrong that would be great as just now I have users saying I have corrupted their files.
Edited by G_Waddell: n/a