|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-05-01 19:23 UTC] colder@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 13 11:00:01 2025 UTC |
Description: ------------ 5.2.6RC starts behaving very strangely if you have a code that sets chmod and chown on the new file being uploaded. This function used to work before, and now it starts causing issues. It seems to crash on chmod, chown, and chgrp Reproduce code: --------------- function handleFileUpload($uploadpath, $filenameprepend, $filesField) { $filename = NULL; if (isset($_FILES[$filesField]['name']) && !empty($_FILES[$filesField]['name']) ) { $pinfo = pathinfo($_FILES[$filesField]['name']); $extn = strtolower($pinfo['extension']); $uploaddir = $uploadpath; $filename = $filenameprepend . '.' . $extn; $uploadfile = $uploaddir . $filename; move_uploaded_file($_FILES[$filesField]['tmp_name'], $uploadfile); sleep(2); chmod($uploadfile,"0666"); chown($uploadfile,$this->getSystemUser()); chgrp($uploadfile,$this->getSystemGroup()); } return $filename; } Expected result: ---------------- The above code block worked on 5.2.4. I believe this is being caused by Fixed move_uploaded_file() to always set file permissions of resulting file according to UMASK. (Andrew Sitnikov) It should set the mode and ownership and group IF the user is explicitly coding it in. Actual result: -------------- Errors like the following show up Warning: chown() [function.chown]: Operation not permitted in /home/chinajapantraders/www/scripts/generalfunctions.php on line 43 Warning: chgrp() [function.chgrp]: Operation not permitted in /home/chinajapantraders/www/scripts/generalfunctions.php on line 44 chmod doesnt give an error, however, the modes arent being set correctly either. The modes show up as : --w--wx-wT if i set it as 0666 as mentioned above.