file upload
hi
i'm trying to upload a file using htmlinputfile control and one server button control to retrieve the information about the file uploaded.
here i use in aspx page
<form id="Form1" method="post" runat="server" ncType="multipart/form-data">
<input type="file" id="MyFile" runat="server" >
<asp:Button id="saveimage" runat="server" Text="Upload"></asp:Button>
</form>
so in cs file i wrote
private void Upload_Click(object sender, System.EventArgs e)
{
try
{
string filename = File.PostedFile.FileName;
int len= File.PostedFile.ContentLength;
}
catch(Exception ex)
{
Console.WriteLine(ex.Message.ToString());
}
}
it always throw exception like
Object reference not set to an instance of an object
i couldn't get the solution.wht'll be solution for tht plz solve it.
thanx in advance
with regards
swagat
|