How can I upload images in my aspx page?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • karimkhan
    New Member
    • Jan 2011
    • 54

    How can I upload images in my aspx page?

    Hi all,

    I want to let user to upload images on my site and put some discription too!

    I want that these things should be saved in my database too.SO how can I achieve this?
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Use the FileUpload control to allow the user to upload a file to the server.

    Add a TextBox to the page so that they can enter a description.

    Add a button so that the user can submit the page to the server. In that button click code, retrieve the file and either store it in database or in a file on the server...and store the description that the user entered into the database.

    Comment

    • PsychoCoder
      Recognized Expert Contributor
      • Jul 2010
      • 465

      #3
      First in my opinion it's bad practice to store images in the database. Going that route uses much more resources. If you are dead set on doing it that route then take a look at this blog post.

      Comment

      • karimkhan
        New Member
        • Jan 2011
        • 54

        #4
        Originally posted by PsychoCoder
        First in my opinion it's bad practice to store images in the database. Going that route uses much more resources. If you are dead set on doing it that route then take a look at this blog post.
        yeah i think you right, my one of friend also told me same, can you suggest me way for how to store it at some folder, and latter how can I retrieve it back when i want!

        Comment

        • karimkhan
          New Member
          • Jan 2011
          • 54

          #5
          dear on button click event what code behind I have to write that i exactly dont know so want help regarding that!

          Comment

          • Frinavale
            Recognized Expert Expert
            • Oct 2006
            • 9749

            #6
            Upload the photo to a folder in the website (maybe call it Images so you know what it's for and it makes sense in a URL path).

            Store the name of the photo in the database.

            When you retrieve the data to display it later, concatenate the photo name retrieved from the database with the url path to the folder when the image resides...and display it in an Image control (or html <img>).

            -Frinny

            Comment

            • karimkhan
              New Member
              • Jan 2011
              • 54

              #7
              CAn you please help me more??
              I know this concept but getting hanged in programming!

              Comment

              • PsychoCoder
                Recognized Expert Contributor
                • Jul 2010
                • 465

                #8
                Did you look through the link I posted showing how to do what you're doing it?

                Comment

                • Frinavale
                  Recognized Expert Expert
                  • Oct 2006
                  • 9749

                  #9
                  What exactly are you stuck on?
                  The uploading part?
                  The displaying part?
                  The saving into the database part?

                  -Frinny

                  Comment

                  Working...