Is it possible to read the content of a file using Fileupload.
For example I want to save the XML file in Database , a user search the file using Fileupload and then click a button to save the content of the file in Database.
I tried this one but doesn't work
string s=Fileuploder1.Filecontent.tostring();
but no success,Do you have any idea?
The HttpPostedFileBase class is an abstract class that contains the same members as the HttpPostedFile class. The HttpPostedFileBase class lets you create derived classes that are like the HttpPostedFile class, but that you can customize and that work outside the ASP.NET pipeline.
ASP.NET FileUpload control allows us to upload files to a Web Server or storage in a Web Form. The control is a part of ASP.NET controls and can be placed to a Web Form by simply dragging and dropping from Toolbox to a WebForm. The FileUpload control was introduced in ASP.NET 2.0.
The HasFile property gets a value indicating whether the FileUpload control contains a file to upload. Use this property to verify that a file to upload exists before performing operations on the file.
string inputContent;
using (StreamReader inputStreamReader = new StreamReader(InputFileUpload.PostedFile.InputStream))
{
inputContent = inputStreamReader.ReadToEnd();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With