close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Page Refresh After Upload - Images do not update.

Thread began 5/05/2010 1:09 pm by Mikel Jones | Last modified 5/06/2010 9:12 am by Jason Byrnes | 12570 views | 9 replies |

Mikel Jones

Page Refresh After Upload - Images do not update.

I have a page set up to both display an image in an image field and also allow upload of the same image via DFP.

The file uploads correctly however the image on the page fails to update (refresh) after the upload is complete. Even though the image on the server has uploaded correctly the image field does not show the new image, it displays the old image instead.

If I leave the page then come back to it the image does not update. I need to do a Ctrl+F5 refresh of the page to get it to display the image correctly.


I figure this is a cache issue but Im at a loss as to how to handle it.

Sign in to reply to this post

Jason ByrnesWebAssist

look at the code order, I bet the recordset that is used to display the image is on the p[age before the update record server behavior.

You will need to move the recordset code so that the recordset is created after the record is updated.

Sign in to reply to this post

Mikel Jones

Originally Said By: Jason Byrnes
  look at the code order, I bet the recordset that is used to display the image is on the p[age before the update record server behavior.

You will need to move the recordset code so that the recordset is created after the record is updated.  



That was it!

You rock bro!

:)


********* Ooops! No that was not it. See my next post. ***********



-

Sign in to reply to this post

Mikel Jones

I spoke to soon.

That fixed one issue but the images still do not update after the file upload.

In fact they do not update even after leaving and coming back to the page. I have to do a Ctrl + F5 refresh to get them to show up after they are changed.

Linkage: test.php

Go ahead and upload an image. Everything works great except the images do not update in the image fields.

If you reload the page and then refresh it the images reload. I checked the server and the images are uploading correctly.

This really looks like a cache issue with the page. I set the cache-control to "no-cache" with no joy.

Sign in to reply to this post

Mikel Jones

More Information...

It seems to be related to the fact that the image file name does not change when the file is uploaded.

The way the page displays the image it just checks to see if the static image file exists "file_exists( 'filename.jpg' )" and if it does it displays it. I upload the same file names every time the user changes their head shot image or company logo. The file names never change, the images are just overwritten every time.

I created a page that changes the name when the file is uploaded and another page that keeps the file name static. The page with the name change updates correctly while the page with the static file name never updates at all unless the client forces a refresh of the page manually (ctrl+F5).

I don't have any idea how to solve this. It seems like a long way around the block to save the file name in the db and have it increment the name every time they upload a file. Not only is it a pain, but it is a waste of db resources.

Sign in to reply to this post

Jason ByrnesWebAssist

Send a copy of the page, I'll need to see the code to be abler to get an idea of whats wrong.

Sign in to reply to this post

Mikel Jones

Originally Said By: Jason Byrnes
  Send a copy of the page, I'll need to see the code to be abler to get an idea of whats wrong.  



The file is zipped and attached to this post.

Note: See my my last post about the static file name and my thoughts on whats happening.

Attached Files
file.zip
Sign in to reply to this post

Jason ByrnesWebAssist

Yeah, I think your right that it is a cache issue.

Try adding the servers time as a querystring on the image source to fool the browser into reloading it:
<img src="../images/Users/1/CoLogo.jpg?<?php echo(time()); ?>" width="150" height="100" alt="Company Logo" />

Sign in to reply to this post

Mikel Jones

Originally Said By: Jason Byrnes
  Yeah, I think your right that it is a cache issue.

Try adding the servers time as a querystring on the image source to fool the browser into reloading it:
<img src="../images/Users/1/CoLogo.jpg?<?php echo(time()); ?>" width="150" height="100" alt="Company Logo" />  




OK I am now convinced that you're a genius. :)

That one goes in my bag of tricks for sure.


Thanks for all the help. Your solution worked great and I am now a happy camper.


--

Sign in to reply to this post

Jason ByrnesWebAssist

Glad to hear it worked.

Google can make anyone look like a genius:
search?btnG=1&pws=0&q=force+browser+to+reload+images+even+if+they+have+been+cached

I got the idea from the first thread in the google results.

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...