Uploading Images

Posted on 2008-11-16
Last Modified: 2013-11-07
I am upgrading my current website to be able to upload two images to the website so visitors can see the product they may be purchasing. I am using the 2.0 in I would like to use the file upload that is provided. However, when that file is uploaded, I want it to upload to my server and not my sql database. The column in the sql database will have the link to that file.  I have searched all over and haven't been able to find a way to do this or if it is even more efficient to do it in this way. To clarify more, this is what I am looking to do:

User uploads an image to my server.
The image is stored in a file folder on my server
A link to the image is stored in a column in my sql database.

Note: If it is more efficient, I could store the image in the database itself.  Thanks for any help you can provide.
Question by:smitty68521
    LVL 6

    Expert Comment

    Wouldn't simply performing an SQL query to your database, retrieving the url you stored in the row and then setting the image location to a dynamic variable you populate via an SQL query be easier?
    LVL 9

    Expert Comment

    If you want to upload images to your server image folder, then I suggest you use
    Quteftp    or something similar to transfer the files.
    LVL 1

    Author Comment

    That is my goal. To populate the sql database column with the link to the image that is stored on the server. Where I am stuck, is how to make that happen. That is to upload the url to the database column to the image that is stored on my server.
    LVL 2

    Accepted Solution

    use file_Base like = "~/images/"

    Public Function Upload_File(ByVal UpldCtrl As FileUpload, ByVal File_Base As String) As String 
    Dim Filename As String = "" 
    Dim File_ex As String = "" 
    If UpldCtrl.HasFile Then 
    Filename = UpldCtrl.FileName 
    UpldCtrl.SaveAs(Server.MapPath(File_Base) & Filename) 
    Catch ex As Exception 
    Filename = "" 
    End Try 
    End If 
    Return Filename 
    End Function 

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now