Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 20th, 2006, 02:16 AM
Registered User
Join Date: Aug 2005
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default file upload

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>

so in cs file i wrote
private void Upload_Click(object sender, System.EventArgs e)
              string filename = File.PostedFile.FileName;
            int len= File.PostedFile.ContentLength;

            catch(Exception ex)


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

  #2 (permalink)  
Old February 20th, 2006, 06:26 AM
Friend of Wrox
Join Date: Jun 2004
Location: Chennai, Tamil Nadu, India.
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to r_ganesh76

Hi Swagat

use the object name insted of the classname

string filename = MyFile.PostedFile.FileName;
int len= MyFile.PostedFile.ContentLength;


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Filter File Types in ASP.NET File Upload ramuis78 ASP.NET 2.0 Basics 2 May 31st, 2007 10:50 AM
file upload asudhakar C# 1 April 4th, 2007 07:29 AM
Whole Folder upload(Multi file Upload) ramasamy_rams XML 1 September 9th, 2005 12:43 PM
JSP file upload and delete file pandjie JSP Basics 0 January 29th, 2005 10:49 PM
Upload file hbcontract XML 2 November 6th, 2003 07:54 PM

All times are GMT -4. The time now is 12:00 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.