开发者

WebClient.UploadFile issue

I am using VSTS 2008 + C# + .Net 3.5 + ASP.Net. I am using WebClient.UploadFile to upload file to a server running with ASP.Net (I use http post to upload the file to a aspx url). My question is, ho开发者_运维知识库w to save the content of the file at server side? I find from server side, if I simply save HttpContext.Current.Request.InputStream, additional request headers (besides file content) will be saved at server side.

EDIT 1:

I have tried I need to have some code like this to receive file at server side? Is that correct code?

    foreach (string f in Request.Files.AllKeys)
    {
        HttpPostedFile file = Request.Files[f];
        file.SaveAs(@"D:\FileUpload\UploadFile.dat");
    } 

thanks in advance, George


You can read the stream into a byte array and then save the byte array in a varbinary(max) field in SQL server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜