Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Upload file without using file upload control

Upload file without using file upload control

Scheduled Pinned Locked Moved ASP.NET
csharpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member 8340587
    wrote on last edited by
    #1

    I want to use file upload in my website, without using file upload control. I have used an asp textbox & an asp button. On clicking the button, the path of the file to be uploaded, comes in text box. Now, how can I upload the file whose path is there in the text box. Code that I used till now for button click is given below: protected void btnUpload_Click(object sender, EventArgs e) { OpenFileDialog fdlg = new OpenFileDialog(); fdlg.Title = "C# Corner Open File Dialog"; fdlg.InitialDirectory = @"c:\"; fdlg.Filter = "All files (*.*)|*.*|All files (*.*)|*.*"; fdlg.FilterIndex = 2; Thread stathread = new Thread(new ThreadStart(() => fdlg.ShowDialog())); stathread.SetApartmentState(ApartmentState.STA); stathread.IsBackground = true; stathread.Start(); stathread.Join(); txtUpload.Text = fdlg.FileName; }

    J 1 Reply Last reply
    0
    • M Member 8340587

      I want to use file upload in my website, without using file upload control. I have used an asp textbox & an asp button. On clicking the button, the path of the file to be uploaded, comes in text box. Now, how can I upload the file whose path is there in the text box. Code that I used till now for button click is given below: protected void btnUpload_Click(object sender, EventArgs e) { OpenFileDialog fdlg = new OpenFileDialog(); fdlg.Title = "C# Corner Open File Dialog"; fdlg.InitialDirectory = @"c:\"; fdlg.Filter = "All files (*.*)|*.*|All files (*.*)|*.*"; fdlg.FilterIndex = 2; Thread stathread = new Thread(new ThreadStart(() => fdlg.ShowDialog())); stathread.SetApartmentState(ApartmentState.STA); stathread.IsBackground = true; stathread.Start(); stathread.Join(); txtUpload.Text = fdlg.FileName; }

      J Offline
      J Offline
      Jack Li
      wrote on last edited by
      #2

      u used

      OpenFileDialog

      ,you select file,but u don't loadup the file,you'll used file class, filecopy to you setting path.

      InitialDirectory = @"c:\";

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups