我发誓昨天工作了.然而,现在下面的代码破坏文件夹没有问题,但创建一个具有411权限的新文件夹应该是777.我的代码昨天这样做.
这样做的目的是压缩文件夹,传递文件夹,删除图像,然后为图像创建新目录.
有人能告诉我我做错了什么或我应该做什么?谢谢
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))
unlink($dirname."/".$file);
else
delete_directory($dirname.'/'.$file);
}
}
closedir($dir_handle);
rmdir($dirname);
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.
$zipName="jigsaw.zip";
include_once("createzipfile/CreateZipFile.inc.php");
$createZipFile=new CreateZipFile;
/*
// Code to Zip a single file
$createZipFile->addDirectory($outputDir);
$fileContents=file_get_contents($fileToZip);
$createZipFile->addFile($fileContents, $outputDir.$fileToZip); …Run Code Online (Sandbox Code Playgroud) 以下PHP脚本无法创建目录.它也将无法创建文件(当目录已存在时).
ini_set('error_reporting', E_ALL);
define('ABSPATH', $_SERVER['DOCUMENT_ROOT']);
echo ABSPATH . '<br /><br />';
$dir_to_make = ABSPATH . '/aaatest';
$file_to_make = ABSPATH . '/aaatest/aaatest.txt';
echo umask() . '<br />';
mkdir($dir_to_make) or die('could not create directory');
fopen($file_to_make) or die('could not open/create file');
Run Code Online (Sandbox Code Playgroud)
umask()返回值18.文档根目录中有一个句点(/var/www/blah/websitename.com/httpdocs).
我不完全理解umask(),也不确定如何正确使用它.我不知道这是不是问题,但似乎确实存在问题.我应该更改umask,创建文件/目录,然后将其更改回来吗?umask应该改变/制作/编辑文件/目录是什么?服务器应该配置不同吗?