php - mkdir() php 函数问题

标签 php html directory

索引.php

<html>
    <body>
        <form action="createfolder.php" method="post" >
        <table width="400" border="0" cellspacing="0" cellpadding="5">
          <tr>
            <td colspan="3" align="center">Please write gallery name and description</td>
          </tr>
          <tr>
            <td>Name </td>
            <td>&nbsp;</td>
            <td><input type="text" name="gname" id="text" value=""></td>
          </tr>
          <tr>
            <td>Description</td>
            <td>&nbsp;</td>
            <td><textarea name="gdescription" cols="30" rows="5" id="textarea"></textarea></td>
          </tr>
          <tr>
            <td colspan="3" align="center"><input type="submit" name="submit" id="submit" value="Submit"></td>
          </tr>
        </table>
        </form>
    </body>
</html>

创建文件夹.php

    <?php

$name = $_POST['gname'];
$dirPath = "images/".$name;
$result = mkdir($dirPath, 0755);
if ($result == 1) {
    echo $dirPath . " has been created";
} else {
    echo $dirPath . " has NOT been created";
}
?>

制作目录时遇到问题。错误: this is the error

最佳答案

是因为用户目录下没有文件

file_exists — 检查文件或目录是否存在并

is_dir — 判断文件名是否为目录

  if (is_dir("path") === true ){
                echo "DIRECTORY: ".$entry."\n";
            }

$filename = '/path/foo.txt';

if (file_exists($filename)) {
    echo "The file $filename exists";
}

关于php - mkdir() php 函数问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13355157/

相关文章:

javascript - 多个选项卡列表 : How to show only the content of the clicked tab list?

Powershell命令删除子文件夹而不删除根目录

php - 如何在javascript中读取json?

asp.net - 以编程方式设置要在网页中上传的文件名称

html - 当 flex-direction 设置为 column 时,如何使用 flexbox 将元素对齐到 div 的底部

java - 如何在Java中的同一个jLabel中显示不同的行

windows - 如何删除 yeoman 在 Windows 中创建的文件夹?

php - 使用 PHP 从特定的 div id 获取数据

javascript - 计算所有 EvenChild 元素的值 javascript/php

PHP动态链接列表破坏ajax