-
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
Function UploadMainImage()
'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)
Return True
Case Else
'Not a valid jpeg image
lblMsg.Text = "Not a valid jpeg image"
Return False
End Select
End If
End Function
Sub btnUpload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpload.Click
uploadSucess = UploadMainImage()
End Sub
End Class
Similar Threads
-
By James Graham in forum .NET
Replies: 4
Last Post: 10-23-2011, 02:47 PM
-
By Arjuna in forum Database
Replies: 2
Last Post: 07-25-2007, 03:22 AM
-
By sandhyaharsh in forum Java
Replies: 0
Last Post: 11-15-2005, 06:23 AM
-
By Ganesh Suryanarayana in forum ASP.NET
Replies: 1
Last Post: 08-02-2004, 03:00 PM
-
By Jeff Pipes in forum VB Classic
Replies: 8
Last Post: 11-13-2001, 04:08 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
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
|
Bookmarks