PHP - File download through fread preserving last modification time -


the following script (just relevant part) let me download file:

if ($file = fopen($file, 'r')) {     if(isset($_server['http_range']))     {         fseek($file, $range);     }      while(!feof($file) &&          (!connection_aborted()) &&          ($bytes_send<$new_length))     {         $buffer = fread($file, $chunksize);         print($buffer); //echo($buffer); // possible         flush();         $bytes_send += strlen($buffer);     }     fclose($file); } 

doing this, downloaded file show actual time creation time.

i know how preserve last modification file has on server.

i know can info filemtime don't know how use in combination script above.

before sending output, do

header("last-modified: " . gmdate("d, d m y h:i:s", filemtime($file)) . " gmt"); 

i don't think cause web browser save file locally modification time. think need use type of archive format that, zip.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -