•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 375,199 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,065 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 405 | Replies: 10
![]() |
i have created a website where the user is able to upload images and then they are displayed on and email which is then sent out to the people of there choice.
the problem i am getting is that the images are being cached and then the new images are not displaying.
i have used if file exist to display the images on the email and also used it to unlink the files once they have been used. When the user comes to use the system next time if they upload an image of the same file type then it is displaying the cached version and not the new image. if a image with a different file type is uploaded then it works, but this will only show different images as long as the file type has not been used.
i have tried using this
which has had no effect on the situation. i put the above code inside the head tag is this the correct place to put it. the reason i put it there is because this is usually were the meta tags are placed.
the problem i am getting is that the images are being cached and then the new images are not displaying.
i have used if file exist to display the images on the email and also used it to unlink the files once they have been used. When the user comes to use the system next time if they upload an image of the same file type then it is displaying the cached version and not the new image. if a image with a different file type is uploaded then it works, but this will only show different images as long as the file type has not been used.
i have tried using this
<META HTTP-EQUIV="Pragma" CONTENT="no-cache"> <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
which has had no effect on the situation. i put the above code inside the head tag is this the correct place to put it. the reason i put it there is because this is usually were the meta tags are placed.
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,057
Reputation:
Rep Power: 8
Solved Threads: 229
Yep ! <head> tag is the right place to put meta tags. I haven't come across caching problem, but maybe you can use this.
Source: http://nl2.php.net/header Ex. 2
php Syntax (Toggle Plain Text)
<?php header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past ?>
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
i have tried that and had no joy. i checked on the server to see if it was a problem with the unlink code i have but it is defiantly uploading the images and removing the old files on the server. I know this as the time stamps for when the file was uploaded are changing.
i will have a good search around the web and see what i can find i will post it here if i find anything that works.
i will have a good search around the web and see what i can find i will post it here if i find anything that works.
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,057
Reputation:
Rep Power: 8
Solved Threads: 229
Hey, If you don't have any "processing" in your script, why not redirect the script to the same page ? Will it still have the images in the cache ?
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
the images are being cached on the server i think and this why the same images show up on the emails i think. i am working on adding a random number to the image when it is uploaded and then using the post/get method to retrieve the value of the random number to use to display the image.
if a random number is added to the image then the image that is shown on the email page will always have a different value added to it so it should always show the new images that are uploaded.
well that is the theory behind it anyway weather it works or not is another thing.
if a random number is added to the image then the image that is shown on the email page will always have a different value added to it so it should always show the new images that are uploaded.
well that is the theory behind it anyway weather it works or not is another thing.
is it possible to a random number to a image file without it becoming a part of that file name. what i want to do is where i am displaying the image add a random number so that the image when cached has this number attached to it but it is not part of the path to the file.
so i want it to be displayed by getting the file name then adding the number so that the number changes every time the page is viewed and the image cannot be displayed from the cach
so i want it to be displayed by getting the file name then adding the number so that the number changes every time the page is viewed and the image cannot be displayed from the cach
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,057
Reputation:
Rep Power: 8
Solved Threads: 229
•
•
•
•
is it possible to a random number to a image file without it becoming a part of that file name.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,057
Reputation:
Rep Power: 8
Solved Threads: 229
I don't know what you mean by that.. But, if you use "if file exists" and add a random number to the image, What is the point in storing the filename in the table ?
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
i am storing the files on the server so that they can be recalled when the email is sent out with the images held within it. the reason i want to add the random number after they have been stored is because the images are being cached.
the problem with the images getting cached is if the user comes and uploads a new image with the same file extension it will only show the cached version of the image. i have tried to stop the images getting cached with various different methods which in clude php headers and html meta tags, both methods failed.
so my next attempt at trying to get it show the new images is by adding a random number. if i store the number with the file i have no way of knowing the full path to the file once a random number has been added to it.
i tried a method were the random number that was generated was sent to the other pages with the session_start() function but that through up a load of errors with my code that is working fine without that in.
if i can get it to find the image without the random number attached to it then add this i am hoping this will stop the old images from being displayed on the pages. I know it is a problem with the images being cached because each time the upload page is entered it unlinks the last file that was uploaded.
hope that makes it a bit more clear.
the problem with the images getting cached is if the user comes and uploads a new image with the same file extension it will only show the cached version of the image. i have tried to stop the images getting cached with various different methods which in clude php headers and html meta tags, both methods failed.
so my next attempt at trying to get it show the new images is by adding a random number. if i store the number with the file i have no way of knowing the full path to the file once a random number has been added to it.
i tried a method were the random number that was generated was sent to the other pages with the session_start() function but that through up a load of errors with my code that is working fine without that in.
if i can get it to find the image without the random number attached to it then add this i am hoping this will stop the old images from being displayed on the pages. I know it is a problem with the images being cached because each time the upload page is entered it unlinks the last file that was uploaded.
hope that makes it a bit more clear.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
Similar Threads
- BLUE Screen stop 0x8e (Windows NT / 2000 / XP / 2003)
- STOP Error 0x0000007A, KERNEL_STACK_INPAGE_ERROR (Troubleshooting Dead Machines)
- STOP: 0x0000000A ..... HELP PLEASE! (Troubleshooting Dead Machines)
- Hijack this log, can someone help me please?? (Viruses, Spyware and other Nasties)
- Windows will not start up properly? (Windows NT / 2000 / XP / 2003)
- Checking file on System C (Windows NT / 2000 / XP / 2003)
- boot problems (Windows NT / 2000 / XP / 2003)
Other Threads in the PHP Forum
- Previous Thread: How to pass array values from php to mysql stored procedures??
- Next Thread: Hopefully a straightforward PHP/MySQL question



Linear Mode