Results 1 to 4 of 4

Thread: Upload Files in ASP.NET

  1. #1
    Join Date
    Dec 2008
    Posts
    10

    Upload Files in ASP.NET

    How can I upload a file to a Web server in ASP.NET ?

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: Upload Files in ASP.NET

    use the ASP.NET button control which the the user will click to upload the file he has selected using the file control. As ASP.NET follows event based programming model we can attach a server side event which will respond to clicking of the button. This is done by using the OnClick event handler of the button control. To this event we assign the name of the method which we want to be executed on the server when the user clicks the button. (e.g)

    Code:
    <asp:button id="cmdUpload" name="cmdUpload" runat="server" OnClick="UploadFile" />
    Now we can write C# code within the UploadFile method to save the uploaded file in the server. This code can be written in two ways depending on the number of file controls we have within the page. If there is only a single file control then we can use the PostedFile property of the file control to upload files.

  3. #3
    Join Date
    May 2008
    Posts
    2,389

    Re: Upload Files in ASP.NET

    PostedFile property is of type HttpPostedFile class and contains the following methods and properties which are used for file uploading.

    Properties

    • Property : Description
    • FileName : Returns the full path and name of the uploaded file.
    • ContentType : The MIME type of the uploaded file.
    • ContentLength :The size in bytes of the uploaded file.


    Method

    • Methods : Description
    • SaveAs(Path) : Saves the uploaded file to the specified path.


    If you have multiple file controls within the form you can use the Files property of the Request object which returns a reference to the HttpFileCollection class.

  4. #4
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Upload Files in ASP.NET

    You can refer to the given link for more information about this.

    http://support.microsoft.com/kb/323245.

Similar Threads

  1. Why can’t we upload 2 GB files on Nokia N8?
    By Vicky Woodley in forum Portable Devices
    Replies: 4
    Last Post: 29-11-2010, 09:19 AM
  2. How to Upload Multiple Files in PHP?
    By SKREECH in forum Software Development
    Replies: 5
    Last Post: 03-03-2010, 04:20 AM
  3. Can't upload files on any website
    By Dhiresh in forum Technology & Internet
    Replies: 3
    Last Post: 22-10-2009, 10:31 PM
  4. Download and upload files via vb.net
    By Thunder Chicken in forum Software Development
    Replies: 3
    Last Post: 05-06-2009, 02:48 PM
  5. Upload files to megaupload
    By goatape in forum Technology & Internet
    Replies: 2
    Last Post: 06-10-2008, 12:27 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,116,526.47736 seconds with 16 queries