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. How to open uploaded files

How to open uploaded files

Scheduled Pinned Locked Moved ASP.NET
databasesysadmintutorialquestion
6 Posts 3 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.
  • N Offline
    N Offline
    n_gchaitra
    wrote on last edited by
    #1

    I am uploading files (.doc,.gif,.excel,etc) and storing in the server. Now I want to open those files when i click the link buttons. But I am able to get only the path but how to open it. what changes i need to the following code? Dim SQLString As String = "SELECT filepath FROM pictures WHERE title = '" & BulletedList1.Items(e.Index).Text & "'" Dim dr As Data.SqlClient.SqlDataReader Dim comm As New Data.SqlClient.SqlCommand(SQLString, dbconn) If dbconn.State <> ConnectionState.Open Then dbconn.Open() End If Dim str As String dr = comm.ExecuteReader While dr.Read str = dr.Item(0) End While dr.Close() TextBox1.Text = str

    Chaitra N

    A S 2 Replies Last reply
    0
    • N n_gchaitra

      I am uploading files (.doc,.gif,.excel,etc) and storing in the server. Now I want to open those files when i click the link buttons. But I am able to get only the path but how to open it. what changes i need to the following code? Dim SQLString As String = "SELECT filepath FROM pictures WHERE title = '" & BulletedList1.Items(e.Index).Text & "'" Dim dr As Data.SqlClient.SqlDataReader Dim comm As New Data.SqlClient.SqlCommand(SQLString, dbconn) If dbconn.State <> ConnectionState.Open Then dbconn.Open() End If Dim str As String dr = comm.ExecuteReader While dr.Read str = dr.Item(0) End While dr.Close() TextBox1.Text = str

      Chaitra N

      A Offline
      A Offline
      Abhi
      wrote on last edited by
      #2

      You have to make a little change in your code.. Code: ===== Remove this code --------------- TextBox1.Text = str Apply this code --------------- 1. Take a one image html control on the form. like. 2. In the server side , Write this code.. MyImage.Src = server.mappath("" + str); Hope this will help you, Regards, Abhi

      N 1 Reply Last reply
      0
      • N n_gchaitra

        I am uploading files (.doc,.gif,.excel,etc) and storing in the server. Now I want to open those files when i click the link buttons. But I am able to get only the path but how to open it. what changes i need to the following code? Dim SQLString As String = "SELECT filepath FROM pictures WHERE title = '" & BulletedList1.Items(e.Index).Text & "'" Dim dr As Data.SqlClient.SqlDataReader Dim comm As New Data.SqlClient.SqlCommand(SQLString, dbconn) If dbconn.State <> ConnectionState.Open Then dbconn.Open() End If Dim str As String dr = comm.ExecuteReader While dr.Read str = dr.Item(0) End While dr.Close() TextBox1.Text = str

        Chaitra N

        S Offline
        S Offline
        Sandeep Akhare
        wrote on last edited by
        #3

        Where are you storing the uploaded files at server ? if you want to open any of files then these files should be in current application Virtual directory or another virtual directoy

        Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "

        N 1 Reply Last reply
        0
        • A Abhi

          You have to make a little change in your code.. Code: ===== Remove this code --------------- TextBox1.Text = str Apply this code --------------- 1. Take a one image html control on the form. like. 2. In the server side , Write this code.. MyImage.Src = server.mappath("" + str); Hope this will help you, Regards, Abhi

          N Offline
          N Offline
          n_gchaitra
          wrote on last edited by
          #4

          Thank you Abhi, but image control does not have Src property. I can open a picture file using imageurl property. But how to open other files?

          Chaitra N

          1 Reply Last reply
          0
          • S Sandeep Akhare

            Where are you storing the uploaded files at server ? if you want to open any of files then these files should be in current application Virtual directory or another virtual directoy

            Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "

            N Offline
            N Offline
            n_gchaitra
            wrote on last edited by
            #5

            Even when i keep the files in the current application, how to open that? Are u suggesting Response.redirect

            Chaitra N

            S 1 Reply Last reply
            0
            • N n_gchaitra

              Even when i keep the files in the current application, how to open that? Are u suggesting Response.redirect

              Chaitra N

              S Offline
              S Offline
              Sandeep Akhare
              wrote on last edited by
              #6

              put the anchor tag and give the url of the file you want to open sorry for late reply

              Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "

              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