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
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.
WRITEPATH will give you the path to your uploads folder. You can also apply some validation in the controller when calling your images.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With