Re: [PHP] Pictures and caches

2006-05-18 Thread Richard Lynch
On Thu, May 18, 2006 3:25 am, Gustav Wiberg wrote:
> The thing I want to do is to copy a picturefile to another
> picturefile.

That's what you THINK you want to do...

> The thing is that I want to copy this file, show it , and then delete
> it
> (when it has been shown) .Is this possible?

You're likely to have problems when the user "reloads" (refreshes)
their page -- as well as all sorts of other problems with
forward/backward buttons.

> I want to do this, because of avoiding problems with cache when
> uploading
> file through an admin-online-system... (the customer uses IE)

In that case, what you REALLY need is the URL to be random, and the
same picture file to always be returned (for the picture you want).

See below.

> When I delete the file in code down below, the picture is not shown (I
> guess
> because the browser hasn't rendered out all info?)

It's way worse than that...

> $fileName = "pictures/products/$dbIDProduct1" . "_small";
>
> $ran = strval(mktime()); //Current time
>
> if (file_exists($fileName . ".gif")) {
>
> copy($fileName . ".gif", "pictures/products/1_$ran.gif");
> showpicture("pictures/products/1_$ran.gif", $dbProductName1, 300,
> 150,
> "top");

This presumably dumps out some HTML, which the user does not even get
for a long time, much less the browser ask for the image, so...

> //deletefile("pictures/products/1_$ran.gif");

Yes, this is WAY too early to delete the file.

> }

Try this:


showpicture("pictures/products/$fileName.gif?$ran", $dbProductName1,
300, 150)

The browser will "see" the ?$ran there and HAVE to get a "new" image
URL, even though it's really the same damn picture.

You may want to look into the many many many archived posts from me
that discus PATH_INFO which describe how to get the ?$ran into the
middle part of the URL, so the URL *looks* like a static directory,
even when it's really a dynamic PHP script.  This will default stupid
browser bugs from ancient browsers, and any similar bugs that crop up
in the future browsers.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Pictures and caches

2006-05-18 Thread Stut

Eric Butera wrote:

On 5/18/06, Gustav Wiberg <[EMAIL PROTECTED]> wrote:
I had to do something similar to keep a javascript file from being
cached by an aol proxy.  Heres a simple example that you could change
to suit your needs by changing the js to something like image.php and
making it send image headers and outputting the contents of your file.

1) Rewrite rule in httpd.conf or virtual.conf
===
RewriteRule ^/lib/(.*)/test.js.php /lib/test.js.php [QSA,L]


2) Create test.js.php in /lib/test.js.php
===



3) Access url: http://example.local/lib/4908574987/test.js.php.  You
can create your url like /lib/time()/test.js.php.

This way you don't have to worry about creating and deleting files.


There's no need to use mod_rewrite for this. You'll get the same result 
if you us a url like


$url = '/lib/test.js.php?'.time();

It's a nail, use a hammer not the screwdriver.

-Stut

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Pictures and caches

2006-05-18 Thread Eric Butera

On 5/18/06, Gustav Wiberg <[EMAIL PROTECTED]> wrote:

Hi!

The thing I want to do is to copy a picturefile to another picturefile.
The thing is that I want to copy this file, show it , and then delete it
(when it has been shown) .Is this possible?

I want to do this, because of avoiding problems with cache when uploading
file through an admin-online-system... (the customer uses IE)

When I delete the file in code down below, the picture is not shown (I guess
because the browser hasn't rendered out all info?)

If you want more code, tell me :-)

Best regards
/Gustav Wiberg



$fileName = "pictures/products/$dbIDProduct1" . "_small";

$ran = strval(mktime()); //Current time

if (file_exists($fileName . ".gif")) {

copy($fileName . ".gif", "pictures/products/1_$ran.gif");
showpicture("pictures/products/1_$ran.gif", $dbProductName1, 300, 150,
"top");
//deletefile("pictures/products/1_$ran.gif");

}

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




I had to do something similar to keep a javascript file from being
cached by an aol proxy.  Heres a simple example that you could change
to suit your needs by changing the js to something like image.php and
making it send image headers and outputting the contents of your file.

1) Rewrite rule in httpd.conf or virtual.conf
===
RewriteRule ^/lib/(.*)/test.js.php /lib/test.js.php [QSA,L]


2) Create test.js.php in /lib/test.js.php
===



3) Access url: http://example.local/lib/4908574987/test.js.php.  You
can create your url like /lib/time()/test.js.php.

This way you don't have to worry about creating and deleting files.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Pictures and caches

2006-05-18 Thread Gustav Wiberg

Hi!

The thing I want to do is to copy a picturefile to another picturefile.
The thing is that I want to copy this file, show it , and then delete it 
(when it has been shown) .Is this possible?


I want to do this, because of avoiding problems with cache when uploading 
file through an admin-online-system... (the customer uses IE)


When I delete the file in code down below, the picture is not shown (I guess 
because the browser hasn't rendered out all info?)


If you want more code, tell me :-)

Best regards
/Gustav Wiberg



$fileName = "pictures/products/$dbIDProduct1" . "_small";

$ran = strval(mktime()); //Current time

if (file_exists($fileName . ".gif")) {

   copy($fileName . ".gif", "pictures/products/1_$ran.gif");
   showpicture("pictures/products/1_$ran.gif", $dbProductName1, 300, 150, 
"top");

   //deletefile("pictures/products/1_$ran.gif");

}

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php