Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Image Upload works but...

Status
Not open for further replies.

kliz0328

Programmer
Nov 7, 2005
138
0
0
US
I am using this code to upload an image
Code:
inpFileUp.PostedFile.SaveAs(path)

and am using the HTMLInputFile Control to do so. The image uploads fine, but when the page redisplays the picture is still the old one, unless I refresh the page then it changes. Do I need to call some type of Dispose() method with the save as code above?
 
The browser is probably serving a cached image. You could either disable caching on th page or append a random id to the end of the image name to fool the browser into thinking it is a different image and therefore request a new image on each load of the page.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Is this what I would use to disable the cache? Sorry I am not at work right now so I can't test it.

Response.Expires = 0
 
Yes, there are several methods but I believe that will work.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
what is the best method for this in your opinion?
 
I'd probably use a random id on the image but why don't you just try them and see what you prefer...


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Another option is just to save with a different file name and reset the link to that file. That way you don't run into cache problem when you want to change the file, but you'll get the performance benefits of caching when you want them.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top