DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Urgent: Upload image to database

  1. #1
    Join Date
    Dec 2005

    Urgent: Upload image to database

    I would like to upload an image from the 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.

  2. #2
    Join Date
    Dec 2005
    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

  1. Replies: 7
    Last Post: 07-16-2013, 11:47 PM
  2. Database not properly created
    By Arjuna in forum Database
    Replies: 2
    Last Post: 07-25-2007, 03:22 AM
  3. upload an image file and save on webserver.
    By sandhyaharsh in forum Java
    Replies: 0
    Last Post: 11-15-2005, 07:23 AM
  4. Replies: 1
    Last Post: 08-02-2004, 03:00 PM
  5. Does Database Exist?
    By Jeff Pipes in forum VB Classic
    Replies: 8
    Last Post: 11-13-2001, 05: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
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center