Drew Drew - 1 year ago 128
PHP Question

PHP code mkdir('images','0777') creates a folder with 411 permissions! Why?

I could swear this was working yesterday. Now however the code below destroys the folder with no problem but creates a new folder with 411 permissions when it should be 777. My code was doing this yesterday.

The purpose of this is to zip up a folder, deliver it, delete the images, then create a new directory for the images.

Can someone tell me what I am doing wrong or what i should be doing? Thanks

function delete_directory($dirname) {
if (is_dir($dirname))
$dir_handle = opendir($dirname);
if (!$dir_handle)
return false;
while($file = readdir($dir_handle)) {
if ($file != "." && $file != "..") {
if (!is_dir($dirname."/".$file))
return true;

$directoryToZip="jigsaw/"; // This will zip all the file(s) in this present working directory

$outputDir="/"; //Replace "/" with the name of the desired output directory.

$createZipFile=new CreateZipFile;

// Code to Zip a single file
$createZipFile->addFile($fileContents, $outputDir.$fileToZip);

//Code toZip a directory and all its files/subdirectories

$fd=fopen($zipName, "wb");



Answer Source

Because you should be using the octal literal 0777, not the number-in-a-string "0777", which is actually 01411 in octal.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download