Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Image update problem

Image update problem

Scheduled Pinned Locked Moved ASP.NET
sysadminhelpquestionannouncement
7 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dasumohan
    wrote on last edited by
    #1

    Hi, I have an image, file upload and a button control on my webform. I am uploading a new image and attaching the image to replace my existing image in button click event. It seems to work fine on my local machine. When I deploy and run on the server side, the image upload is working fine, the image is getting replaced in the background. However my web page still shows old image. If I reload the page then it shows the updated image. I am using the same name for the image when I am doing save as in the button click event. Any inputs why this is happening? Appreciate inputs

    Raj D

    V Q V 3 Replies Last reply
    0
    • D dasumohan

      Hi, I have an image, file upload and a button control on my webform. I am uploading a new image and attaching the image to replace my existing image in button click event. It seems to work fine on my local machine. When I deploy and run on the server side, the image upload is working fine, the image is getting replaced in the background. However my web page still shows old image. If I reload the page then it shows the updated image. I am using the same name for the image when I am doing save as in the button click event. Any inputs why this is happening? Appreciate inputs

      Raj D

      V Offline
      V Offline
      Venkatesh Mookkan
      wrote on last edited by
      #2

      I belive, you are not loading the image after the image is uploaded. Could you please post your code for better assistance?

      Regards, Venkatesh Mookkan. Software Engineer, India My: Website | Yahoo Group

      D 1 Reply Last reply
      0
      • D dasumohan

        Hi, I have an image, file upload and a button control on my webform. I am uploading a new image and attaching the image to replace my existing image in button click event. It seems to work fine on my local machine. When I deploy and run on the server side, the image upload is working fine, the image is getting replaced in the background. However my web page still shows old image. If I reload the page then it shows the updated image. I am using the same name for the image when I am doing save as in the button click event. Any inputs why this is happening? Appreciate inputs

        Raj D

        Q Offline
        Q Offline
        qiangtian
        wrote on last edited by
        #3

        Meybe cache? try Response.Cache.SetCacheability(HttpCacheability.NoCache);

        B 1 Reply Last reply
        0
        • V Venkatesh Mookkan

          I belive, you are not loading the image after the image is uploaded. Could you please post your code for better assistance?

          Regards, Venkatesh Mookkan. Software Engineer, India My: Website | Yahoo Group

          D Offline
          D Offline
          dasumohan
          wrote on last edited by
          #4

          I have the Image1.ImageURL set to the same jpg filename that I am not changing. So in page load event caused by the button click event the image needs to be loaded. If it is reading from the server then it should show the new uploaded image. However it seems to be not retrieving this data from server. Please see the code below that I used. I even set the Image1.ImageURL in the page load event.. Still does not work. It works great on my local system. Please advice Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Image1.ImageUrl = "_SiteURL here_/images/studios/S-arc-0001.jpg" End Sub Protected Sub Button6_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button6.Click Response.Cache.SetCacheability(HttpCacheability.NoCache) If FileUpload1.HasFile Then FileUpload1.SaveAs(MapPath("~/images/studios/S-arc-0001.jpg")) Image1.ImageUrl = "_Site URL here_/images/studios/S-arc-0001.jpg" End If End Sub

          Raj D

          V 1 Reply Last reply
          0
          • Q qiangtian

            Meybe cache? try Response.Cache.SetCacheability(HttpCacheability.NoCache);

            B Offline
            B Offline
            badgrs
            wrote on last edited by
            #5

            Caching would be my guess as well, especially as your using the same file name. You could also try changing the filename to include some timestamp based hash.

            1 Reply Last reply
            0
            • D dasumohan

              I have the Image1.ImageURL set to the same jpg filename that I am not changing. So in page load event caused by the button click event the image needs to be loaded. If it is reading from the server then it should show the new uploaded image. However it seems to be not retrieving this data from server. Please see the code below that I used. I even set the Image1.ImageURL in the page load event.. Still does not work. It works great on my local system. Please advice Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Image1.ImageUrl = "_SiteURL here_/images/studios/S-arc-0001.jpg" End Sub Protected Sub Button6_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button6.Click Response.Cache.SetCacheability(HttpCacheability.NoCache) If FileUpload1.HasFile Then FileUpload1.SaveAs(MapPath("~/images/studios/S-arc-0001.jpg")) Image1.ImageUrl = "_Site URL here_/images/studios/S-arc-0001.jpg" End If End Sub

              Raj D

              V Offline
              V Offline
              Venkatesh Mookkan
              wrote on last edited by
              #6

              dasumohan wrote:

              Image1.ImageUrl = "SiteURL here/images/studios/S-arc-0001.jpg"

              You are using the Absolute URL for Image Path. Use relative path. Say, Image1.ImageUrl = "images/studios/S-arc-0001.jpg"

              dasumohan wrote:

              Response.Cache.SetCacheability(HttpCacheability.NoCache)

              If you need the Cacheability, set it in the Page Load event. The relative path may solve your problem.

              Regards, Venkatesh Mookkan. Software Engineer, India My: Website | Yahoo Group

              1 Reply Last reply
              0
              • D dasumohan

                Hi, I have an image, file upload and a button control on my webform. I am uploading a new image and attaching the image to replace my existing image in button click event. It seems to work fine on my local machine. When I deploy and run on the server side, the image upload is working fine, the image is getting replaced in the background. However my web page still shows old image. If I reload the page then it shows the updated image. I am using the same name for the image when I am doing save as in the button click event. Any inputs why this is happening? Appreciate inputs

                Raj D

                V Offline
                V Offline
                Vasudevan Deepak Kumar
                wrote on last edited by
                #7

                http://www.codeproject.com/script/comments/forums.asp?forumid=12076&mode=all&userid=52123&select=1926528&df=100&fr=143.5#xx1926528xx[^]

                Vasudevan Deepak Kumar Personal Homepage Tech Gossips

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups