UploadFile Management - Receive Data

How to get data (reading a file) selected in a FileUpload control without FileUpload.SaveAs Methodon a server? Is it possible to immediately write it to some object?

+3
source share
2 answers

Using FileUpload.FileContentgives you Streamto work.

See MSDN .

For instance:

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));
    }
}
+2
source

You have access to the download byte [] using

FileUpload1.FileBytes

where FileUpload1 is a control.

+1
source

Source: https://habr.com/ru/post/1792879/


All Articles