File Upload

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • suneeth
    New Member
    • Mar 2008
    • 4

    File Upload

    how do i upload a file from a default location in the client machine in asp.net using c# ?.To be made more clear, instead of using the browse button, when i click the upload button the file in a particular location must be automatically uploaded.
    Please reply to me as early as possible....
  • venkat245
    New Member
    • Mar 2008
    • 5

    #2
    Hi
    keep this code in button
    may be this is useful of u

    [code=cpp]
    if (FileUpload1 .HasFile)
    {

    FileUpload1.Sav eAs("C:/Documents and Settings//Desktop/sample/"+ FileUpload1.Fil eName.ToString( ));
    Label1.Text = "File Uploaded: " + FileUpload1.Fil eName;
    }
    else
    {
    Label1.Text = "No File Uploaded.";
    }[/code]
    Last edited by Frinavale; Mar 29 '08, 03:39 PM. Reason: added [code] tags

    Comment

    • suneeth
      New Member
      • Mar 2008
      • 4

      #3
      Thank you for your reply.But,shoul d i use the file upload component here?

      Comment

      • balabaster
        Recognized Expert Contributor
        • Mar 2007
        • 798

        #4
        Where are you uploading to? A web server, ftp server? Can you give us some more detail on what you are trying to achieve?

        Comment

        • Frinavale
          Recognized Expert Expert
          • Oct 2006
          • 9749

          #5
          Originally posted by suneeth
          Thank you for your reply.But,shoul d i use the file upload component here?
          You should be using the FileUpload control if you are uploading files from the client's computer to the web server in an ASP.NET web application (ie. if you are uploading files through a web browser).

          Take a look a the FileUpload Control for more information on how to upload files and code examples in both C# and VB.NET.

          -Frinny

          Comment

          • suneeth
            New Member
            • Mar 2008
            • 4

            #6
            Thank you all for your response.
            I can make my question more clear.
            I am coding for a program in which i need to capture data from a text file(default location.there should not be any need for the user to use browse button).When the user clicks the button the data in the text file should be automatically broght to a text box.(the text file may contain not more than 2 or 3 digits)

            Comment

            • GregoryPankov
              New Member
              • May 2008
              • 6

              #7
              Hello!

              As I can see you are trying to get an acess to file system on the client's machine. It is cannot be done with standart html elements or javascript(secu rity model).

              FileUpload control is rendered on client side to
              Code:
              <input type=file name=file1>
              , so it's the same standart html.

              So, you can use some activex or java applet for solving your task.

              Comment

              Working...