note 114982 added to function.move-uploaded-file
| From: | ChrisHecker | Date: | Fri, 09 May 2014 06:26:42 +0000 |
| Subject: | note 114982 added to function.move-uploaded-file | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-199490@lists.php.net to get a copy of this message | ||
Re: Florian S. in H. an der E. [.de]'s point about directory stick bits, I got hit by this a
bunch since I use groups and dir sticky bits to secure my site, so I wrote this replacement, which
others might find useful:
/**
* obey sticky bit with move_uploaded_file
*
*/
function wp_move_uploaded_file( $filename, $destination ) {
define("STICKYGRPDIR",042010);
$stat = stat(dirname($destination));
if(move_uploaded_file($filename,$destination)) {
if($stat['mode'] & STICKYGRPDIR) {
return chgrp($destination,$stat['gid']);
}
} else {
return false;
}
}
----
Server IP: 72.52.91.14
Probable Submitter: 50.131.186.213
----
Manual Page -- http://php.net/manual/en/function.move-uploaded-file.php
Edit -- https://master.php.net/note/edit/114982
Del: integrated -- https://master.php.net/note/delete/114982/integrated
Del: useless -- https://master.php.net/note/delete/114982/useless
Del: bad code -- https://master.php.net/note/delete/114982/bad+code
Del: spam -- https://master.php.net/note/delete/114982/spam
Del: non-english -- https://master.php.net/note/delete/114982/non-english
Del: in docs -- https://master.php.net/note/delete/114982/in+docs
Del: other reasons-- https://master.php.net/note/delete/114982
Reject -- https://master.php.net/note/reject/114982
Search -- https://master.php.net/manage/user-notes.php