Hello, anyone
I had search for few days with how to save file when user choose a file name from listbox and i will search the file from database and user can save it into their desktop
what I had done currently is uploading a file to database but totally no idea about how to "download" from database
the following is my codes to upload file to database:
[code=vbnet]
If Not (myFile.PostedF ile Is Nothing) Then
OpenConn()
Dim intFileNameLeng th As Integer, bytData() As Byte
Dim objStream As System.IO.Strea m
Dim strFileNamePath As String
Dim strFileNameOnly As String
intFileNameLeng th = myFile.PostedFi le.ContentLengt h
ReDim bytData(intFile NameLength)
objStream = myFile.PostedFi le.InputStream
objStream.Read( bytData, 0, intFileNameLeng th)
strFileNamePath = myFile.PostedFi le.FileName
intFileNameLeng th = InStr(1, StrReverse(strF ileNamePath), "\")
strFileNameOnly = Mid(strFileName Path, (Len(strFileNam ePath) - intFileNameLeng th) + 2)
Dim cmd As OracleCommand
cmd = New OracleCommand(" INSERT INTO test (filename, filesave) Values ('" + strFileNameOnly + "',:1)", myCN)
cmd.CommandType = CommandType.Tex t
Dim param As OracleParameter = cmd.Parameters. Add("filesave", OracleDbType.Bl ob) ' Bind the parameter as OracleDbType.Bl ob to command for inserting image
param.Direction = ParameterDirect ion.Input
param.Value = bytData ' Assign Byte Array to Oracle Parameter
cmd.ExecuteNonQ uery()
CloseConn()
Label1.Text = "File Upload Success."
End If
[/code]
Please help me/ giv me some direction to go, I hav no idea at all
Thanks in advance
I had search for few days with how to save file when user choose a file name from listbox and i will search the file from database and user can save it into their desktop
what I had done currently is uploading a file to database but totally no idea about how to "download" from database
the following is my codes to upload file to database:
[code=vbnet]
If Not (myFile.PostedF ile Is Nothing) Then
OpenConn()
Dim intFileNameLeng th As Integer, bytData() As Byte
Dim objStream As System.IO.Strea m
Dim strFileNamePath As String
Dim strFileNameOnly As String
intFileNameLeng th = myFile.PostedFi le.ContentLengt h
ReDim bytData(intFile NameLength)
objStream = myFile.PostedFi le.InputStream
objStream.Read( bytData, 0, intFileNameLeng th)
strFileNamePath = myFile.PostedFi le.FileName
intFileNameLeng th = InStr(1, StrReverse(strF ileNamePath), "\")
strFileNameOnly = Mid(strFileName Path, (Len(strFileNam ePath) - intFileNameLeng th) + 2)
Dim cmd As OracleCommand
cmd = New OracleCommand(" INSERT INTO test (filename, filesave) Values ('" + strFileNameOnly + "',:1)", myCN)
cmd.CommandType = CommandType.Tex t
Dim param As OracleParameter = cmd.Parameters. Add("filesave", OracleDbType.Bl ob) ' Bind the parameter as OracleDbType.Bl ob to command for inserting image
param.Direction = ParameterDirect ion.Input
param.Value = bytData ' Assign Byte Array to Oracle Parameter
cmd.ExecuteNonQ uery()
CloseConn()
Label1.Text = "File Upload Success."
End If
[/code]
Please help me/ giv me some direction to go, I hav no idea at all
Thanks in advance
Comment