Urgent: Upload image to database
I would like to upload an image from the vb.net webform into the database. I am
not using BLOB. Instead I store the image's path name into the database. Can anyone give me an idea on how to upload the image using this method? I had tried searching on google but most of the examples that I fouind is using BLOB.Please help.
I had managed to upload the file to the specific folder but I would like to rename the file upon upload. Below is my code. Can anyone help me on renaming the file upon upload? Thank you
'Check to make sure we actually have a file to upload
If Not (fileUpload1.PostedFile Is Nothing) Then
Dim strLongFilePath As String = fileUpload1.PostedFile.FileName
Dim intFileNameLength As Integer = InStr(1, StrReverse(strLongFilePath), "\")
strFileName = Mid(strLongFilePath, (Len(strLongFilePath) - intFileNameLength) + 2)
Select Case fileUpload1.PostedFile.ContentType
'Make sure we are getting a valid JPG image
Case "image/pjpeg", "image/jpeg"
filepath = Server.MapPath("\") & "\samplelogin\images\upload\"
fileUpload1.PostedFile.SaveAs(filepath & strFileName)
'Not a valid jpeg image
lblMsg.Text = "Not a valid jpeg image"
Sub btnUpload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpload.Click
uploadSucess = UploadMainImage()
By James Graham in forum .NET
Last Post: 07-17-2013, 12:47 AM
By Arjuna in forum Database
Last Post: 07-25-2007, 04:22 AM
By sandhyaharsh in forum Java
Last Post: 11-15-2005, 07:23 AM
By Ganesh Suryanarayana in forum ASP.NET
Last Post: 08-02-2004, 04:00 PM
By Jeff Pipes in forum VB Classic
Last Post: 11-13-2001, 05:08 PM
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL