Hi:
I'm uploading documents into a SQL Server Image field and using
Response.Binary Write() to download or view them in the browser. Some doc
types like Adobe Illustrator and Photoshop files will open correctly, but
other like Word, Excel and Powerpoint are corrupt. Here is code fragment to
upload:
// Get file in byte array
int fileLen = this.TextBoxFil eToUpload.Poste dFile.ContentLe ngth;
byte[] arrayFile = new byte [fileLen];
Stream strm = this.TextBoxFil eToUpload.Poste dFile.InputStre am;
string contentType = this.TextBoxFil eToUpload.Poste dFile.ContentTy pe;
strm.Read(array File, 0, fileLen);
// Run insert commands...
Here is download code fragment:
// Get data into a reader...
// write to browser
Response.Conten tType = reader["ContentTyp e"].ToString();
Response.Append Header("Content-Disposition", "attachment ; filename = " +
fileName);
Response.Binary Write((byte[]) reader["FileConten ts"]);
Should work, seems like I'm missing something.
Thanks,
Charlie