开发者

UploadFile control - get data

How to get data (read file) chosen in FileUpload control without FileUpload.SaveAs Met开发者_如何学Pythonhod on the server? Is it possible write it at once to some object?


Using FileUpload.FileContent gives you a Stream to work with.

See MSDN.

For example:

void WriteFileLength()
{
    if (fileUpload.HasFile)
    {
        var fileStream = fileUpload.FileContent;
        var messageFormat = "The file is {0} bytes in length"
        Response.Write(string.Format(messageFormat, fileStream.Length));
    }
}


You have access to the byte[] of the upload by using

FileUpload1.FileBytes

where FileUpload1 is the control.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜