php codeigniter 创建目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6245965/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 23:46:12  来源:igfitidea点击:

codeigniter creating a directory

phpcodeigniter

提问by koool

How do I create a directory using codeigniter? Basically what I am trying to do is allow user to upload files and then create a directory on the fly for storing these file could anyone point me on how could I create a directory using codeigniter

如何使用 codeigniter 创建目录?基本上我想要做的是允许用户上传文件,然后动态创建一个目录来存储这些文件,任何人都可以指点我如何使用 codeigniter 创建目录

Thanks All efforts will be appreciated

感谢所有的努力将不胜感激

回答by Anjuman

I have run the following codes in windows which works perfect for me-

我已经在 Windows 中运行了以下代码,这对我来说非常合适-

    <?php

    $path = "uploads/product";

    if(!is_dir($path)) //create the folder if it's not already exists
    {
      mkdir($path,0755,TRUE);
    } 

    ?>

Here 0755 is permission of the folder to be created. 755 means you can do anything with the file or directory, and other users can read and execute it but not alter it. Suitable for programs and directories you want to make publicly available.

这里 0755 是要创建的文件夹的权限。755 意味着您可以对文件或目录执行任何操作,其他用户可以读取和执行它,但不能更改它。适用于您想要公开的程序和目录。

回答by Paris Liakos

Use mkdir

使用mkdir

mkdir("/path/to/my/dir");