Reputation: 956
My issue isn't that the folder is getting written, it's the permissions that it's being written with. Here is the code I'm using the write the file:
// check if the file/folder exists
$targetPath = 'files/docmoga/';
if(!file_exists($targetPath)){
$oldmask = umask(0);
mkdir($targetPath, '0777', true);
umask($oldmask);
}
move_uploaded_file($tempFile, $targetFile);
It's failing on the last line because of permissions. Here are the permissions the folder is being written with:
dr----x--t 2 apache apache 4096 May 4 09:17 docmoga
What might be happening to cause the permissions to being written incorrectly for that folder? If it helps I'm using laravel as a framework which I know shouldn't mean anything.
Upvotes: 1
Views: 690
Reputation: 7152
Have you checked what user your script is running under?
Run exec('whoami')
in your script and look at the output. It should be apache
or a user that has the appropriate permissions to create the folder.
Also try to use the literal octal number 0777
vs a string version '0777'
. Taken from https://stackoverflow.com/a/2251293/1133306
Upvotes: 2