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:
Expand|Select|Wrap|Line Numbers
- If Not (myFile.PostedFile Is Nothing) Then
- OpenConn()
- Dim intFileNameLength As Integer, bytData() As Byte
- Dim objStream As System.IO.Stream
- Dim strFileNamePath As String
- Dim strFileNameOnly As String
- intFileNameLength = myFile.PostedFile.ContentLength
- ReDim bytData(intFileNameLength)
- objStream = myFile.PostedFile.InputStream
- objStream.Read(bytData, 0, intFileNameLength)
- strFileNamePath = myFile.PostedFile.FileName
- intFileNameLength = InStr(1, StrReverse(strFileNamePath), "\")
- strFileNameOnly = Mid(strFileNamePath, (Len(strFileNamePath) - intFileNameLength) + 2)
- Dim cmd As OracleCommand
- cmd = New OracleCommand("INSERT INTO test (filename, filesave) Values ('" + strFileNameOnly + "',:1)", myCN)
- cmd.CommandType = CommandType.Text
- Dim param As OracleParameter = cmd.Parameters.Add("filesave", OracleDbType.Blob) ' Bind the parameter as OracleDbType.Blob to command for inserting image
- param.Direction = ParameterDirection.Input
- param.Value = bytData ' Assign Byte Array to Oracle Parameter
- cmd.ExecuteNonQuery()
- CloseConn()
- Label1.Text = "File Upload Success."
- End If
Thanks in advance