Pogledajte određenu poruku
Staro 19. 11. 2008.   #4
kodi
133t
Master
 
Avatar kodi
 
Datum učlanjenja: 07.01.2006
Lokacija: Beograd
Poruke: 714
Hvala: 16
37 "Hvala" u 28 poruka
kodi is on a distinguished road
Pošaljite ICQ poruku za kodi
Default

evo jednog od komentara ispod php.net/header

Citat:
When using PHP to output an image, it won't be cached by the client so if you don't want them to download the image each time they reload the page, you will need to emulate part of the HTTP protocol.

Here's how:
Kôd:
<?php

    // Test image.
    $fn = '/test/foo.png';

    // Getting headers sent by the client.
    $headers = apache_request_headers(); 

    // Checking if the client is validating his cache and if it is current.
    if (isset($headers['If-Modified-Since']) && (strtotime($headers['If-Modified-Since']) == filemtime($fn))) {
        // Client's cache IS current, so we just respond '304 Not Modified'.
        header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($fn)).' GMT', true, 304);
    } else {
        // Image not cached or cache outdated, we respond '200 OK' and output the image.
        header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($fn)).' GMT', true, 200);
        header('Content-Length: '.filesize($fn));
        header('Content-Type: image/png');
        print file_get_contents($fn);
    }

?>
u principu uvek treba slati last modified kad se salje neka slika...
drugi je problem sto su 90% primera po tutorijalima na netu, a i ponekoj knjizi ovakvi:

Kôd:
<?php
$length = strlen($imagedata);
header('Content-Length: '.$length);
header('Content-Type: image/jpeg');
print($imagedata);
?>
tj nigde ni traga od header-a.


e sad, ja stvarno nisam testirao da li ce ovakav pristup definitivno naterati recimo IE6 da promeni sliku.. treba probati.
__________________
kodi je offline   Odgovorite uz citat