아래의 C# 코드를 사용하여 .doc 파일을 SQL Server 데이터베이스에 varbinary(max)
으로 저장합니다..doc 문서를 SQL Server 데이터베이스에 저장하는 방법
파일을 저장할 수 있지만 파일을 다시 가져 와서 웹 페이지의 내용을 표시하려고 할 때 코드가 파일을 다운로드하고 처리하는 방법에 대해 큰 혼란을 겪고 있습니다.
정확하게 찾고 싶은 기능은 naukri.com입니다. 이력서를 업로드하고 미리보기를 제공합니다. 내 코드는 다음과 같습니다 당신이 응용 프로그램/MS-단어에 콘텐츠 형식을 설정하고 있기 때문에
byte[] fileContent = new byte[fuResume.PostedFile.ContentLength];
fuResume.PostedFile.InputStream.Read(fileContent, 0, fuResume.PostedFile.ContentLength);
//lblAppliedMessage.Text = ByteArrayToString(fileContent);
//lblAppliedMessage.Text = BitConverter.ToString(fileContent).Replace("-", string.Empty);
byte[] btYourDoc;
btYourDoc = fileContent;
Response.ContentType = "application/ms-word";
Response.AddHeader("Content-Disposition", "inline;filename=yourfilename.doc");
Response.OutputStream.Write(btYourDoc, 0, fileContent.Length);
Response.BinaryWrite(btYourDoc);
Response.End();
나는 당신과 동의합니다. – Tan