0

I have read this:- Why can't PHP create a directory with 777 permissions?

and I can see a new folder being created by applying the following:-

// Desired folder structure
$structure = "../../../".$flash_dir."HELLO";

// To create the nested structure, the $recursive parameter 
// to mkdir() must be specified.

    $oldmask = umask(0);
    mkdir($structure, 0777);
    umask($oldmask);

when viewing the file permission of HELLO with DreamWeaver, it is 777. However, I suspect it is a Linux 0777 rather than a Windows 777, therefore I still cannot upload things to HELLO.

Will there be any alternative method to create a directory with windows 777? Thanks!

PS. when I manual create a new directory and right click it to set 777, it works perfectly, so I really think it's related to Linux vs Windows~

Community
  • 1
  • 1
Ham
  • 804
  • 3
  • 15
  • 25
  • If on linux you should also check the files owner and group, an upload script owned by root (because up uploaded it or created it as root) but run as www-data cannot upload files owned by a directory created by www-data. enable `error_reporting_(E_ALL);` – Lawrence Cherone Jun 10 '12 at 04:47
  • @LawrenceCherone I always thought that root can read & write whatever & whereever it wants. – noob Jun 10 '12 at 04:54
  • @micha unless apache is running as root then it wont own the file. Scripts are run by the apache process not by who owns them – Lawrence Cherone Jun 10 '12 at 04:59
  • 1
    if you are creating a directory with PHP its owned by the same user who owns the apache process. Now this user can create file on that folder. There should not be any permission problem. – Shiplu Mokaddim Jun 10 '12 at 05:05
  • 1
    @shiplu.mokadd.im seems safemode is on :s – Lawrence Cherone Jun 10 '12 at 05:07

1 Answers1

0

0777 is exactly the same thing as 777

But I still can't say what the problem is. I would try to chmod it again after you've created it.

$oldmask = umask(0);
chmod($structure, 0777);
umask($oldmask);
noob
  • 8,982
  • 4
  • 37
  • 65
  • I further added the above script, but it still shows:- Warning: move_uploaded_file() [function.move-uploaded-file]: SAFE MODE Restriction in effect. The script whose uid is 10400 is not allowed to access /var/www/web92/web/friends/uploads/flash/JJJ owned by uid 48 in /var/www/web92/web/friends/cms/modules/media_upload/process.php on line 96 – Ham Jun 10 '12 at 04:58
  • 1
    SAFE MODE = Damn out of luck, ask your host to turn it off or your off. – Lawrence Cherone Jun 10 '12 at 05:06