You are here: Re: (!mkdir("$username", 0777)) and umask « All PHP « IT news, forums, messages
Re: (!mkdir("$username", 0777)) and umask

Posted by nemo on 11/18/06 23:58

On Sat, 18 Nov 2006 19:29:57 +0100, "J.O. Aho" <user@example.net>
wrote:

>Not here Not Now wrote:
>> $oldumask=umask(0);
>> chmod("$username", 0777);
>> umask($oldumask);
>>
>> Ok tried it plain as just umask with out params
>>
>> Default it should set to 777 still the directory is being created with
>> the permission set to 755.
>
>This may have to do with the users umask values, which usually is 0022.
>Setting it to 0000 should solve your problem.
>
>
> //Aho

This works for me in one of my scripts.
If the directory with the username of the operator uploading a
file.does not exist, it is created and the file uploaded into it. If
it does exist, the file is uploaded into it.
The key piece seemed to be the -
$oldumask=umask(0);

HTH.

<?
session_start();
$username=$_SESSION['username'];
if (!is_dir($username))
{
// create the directory and put the file into this directory;
$oldumask=umask(0);
mkdir($username, 0777) or die ("Could not make directory");
umask($oldumask);
chdir($username);
copy ($file, "$file_name");
}
else
{
// put the file into this directory;
chdir($username);
copy ($file, "$file_name");
}
?>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация