How to open uploaded files
-
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
-
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
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
-
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
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... "
-
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
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
-
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... "
Even when i keep the files in the current application, how to open that? Are u suggesting Response.redirect
Chaitra N
-
Even when i keep the files in the current application, how to open that? Are u suggesting Response.redirect
Chaitra N
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... "