Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

codeigniter creating a directory

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

Thanks All efforts will be appreciated

like image 666
koool Avatar asked Jun 05 '11 21:06

koool


People also ask

What is Fcpath in codeigniter?

EXT: The PHP file extension FCPATH: Path to the front controller (this file) (root of CI) SELF: The name of THIS file (index.php) BASEPATH: Path to the system folder APPPATH: The path to the "application" folder.

What is Writepath in codeigniter 4?

WRITEPATH will give you the path to your uploads folder. You can also apply some validation in the controller when calling your images.

What is the use of core folder in codeigniter?

Core − This folder will contain base class of your application. Helpers − In this folder, you can put helper class of your application. Hooks − The files in this folder provide a means to tap into and modify the inner workings of the framework without hacking the core files.

How do I delete a file in codeigniter 4?

you can use the "file helper" in codeigniter. and like this : $this->load->helper("file"); delete_files($path); Late Edit: delete_files method uses a path to wipe out all of its contents via unlink() and same you can do within CI.


1 Answers

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

    <?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.

like image 121
Anjuman Avatar answered Oct 15 '22 16:10

Anjuman