php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44884 File handling causes issues
Submitted: 2008-05-01 19:13 UTC Modified: 2008-05-01 19:23 UTC
From: assid at assid dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.2.6RC5 OS: debian gnu/linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: assid at assid dot com
New email:
PHP Version: OS:

 

 [2008-05-01 19:13 UTC] assid at assid dot com
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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-05-01 19:23 UTC] colder@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

chmod(.., 0666) and not chmod(.., "0666")
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 20 06:01:34 2024 UTC