note 52781 added to function.touch

From: Date: Thu, 12 May 2005 10:42:33 +0000
Subject: note 52781 added to function.touch
Groups: php.notes 
Request: Send a blank email to php-notes+get-89310@lists.php.net to get a copy of this message
Here's a little workaround that allows the PHP user to touch a file it doesn't own: <?php $target_file = "/path/to/file/filename.txt"; //system filepath to your file $file_content = implode("",file($target_file)); @unlink($target_file); if($savetofile = fopen($target_file, "w")) { fputs($savetofile, $file_content); fclose($savetofile); } $new_date = strtotime("23 April 2005"); // set the required date timestamp here touch($target_file,$new_date); ?> Of course, PHP needs to have write access to the folder containing the file you want to touch, but that should be easy to arrange. ---- Manual Page -- http://www.php.net/manual/en/function.touch.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+52781 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52781&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52781&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52781&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52781&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52781&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+52781&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#89310) next »