![]() $datas = get_file_info('./application/controllers/tests.php') /* it shows the define file on the server */ Of information you want to retrieve from server such as name, server, size and $file: It shows the particular file path in the.get_file_info(): It is used to show the details of the particular file such as file name, server, date, size and the path. The above image shows all the details about the folder or directory suchĪs file names, server, size of files, date and the path of the files.Ħ. When you execute the above program in localhost by invoking the URL localhost/CodeIgniter-3.1.11/index.php/tests/getdirFiles, it shows the output, as shown below. $fetch = get_dir_file_info('./application/controllers', FALSE) /*it shows all the files inside the controllers folder */ $source_dir: It shows the directory path which you want to.get_dir_file_info(): This function is used to get a complete description of all files in a folder or directory. When you execute the above program in localhost by invoking the URL localhost/CodeIgniter-3.1.11/index.php/tests/getFiles, it shows the output, as shown below.ĥ. $get= get_filenames('./application/views/', FALSE) // it shows all the files of views folder The FALSE value represents theĬurrent path of the files, whereas TRUE value shows the complete path of Syntax get_filenames( $source_dir [, $include_pathįolder for shows all the filenames of the defined path in the local server. get_filenames(): As the name suggests, it fetches all the files names on the local server that you have defined in the root folder. Otherwise, it shows 0, it means your file hasnotĭelete the folder or directory with files, use the syntax, given below:Ĥ. In the above image, 1 denotes that the file has been deleted ![]() When you execute the above program in localhost by invoking the URL localhost/CodeIgniter-3.1.11/index.php/tests/deleteFiles, it shows the output, as shown below. $datas = './files/' // it is the path of the files Want to delete the folder or the directory, else set false. $path: It defines the path of the file that we want to.Syntax delete_files( $path [ $del_dir = FALSE [ delete_files(): It is used to delete the existing files from the system. Then it will show a new file in the defined path as ‘myfile1.txt’.ģ. So, you have to make small changes in the path like './files/myfile1.txt'. If the file does not exist in the defined path, it creates a new file,Īutomatically. Note: The write_file() function is used to write content to the specified path. When you execute the above program in localhost by invoking the URL localhost/CodeIgniter-3.1.11/index.php/tests/writeFiles It shows the message File has been updated! as shown below.įrom the CodeIgniter-3.1.11/Files/, it shows the updated text as shown $message = 'Everyone should know how to program a computer, because it teaches you ave to think!' $datas = './files/myfile.txt' // path of the file By default, it is set to ‘wb’.įile in application/controller folder and write the following program. $mode: It defines the mode of the file whether theįile is allowed to be read or write.$data: It defines the new data that we want to.$path: It defines the path of the file.write_file(): It is used to update or modify an existing file that calls to the server by defining a path. When you execute the above program in localhost by invoking the URL localhost/CodeIgniter-3.1.11/index.php/tests/readFiles, it shows the content of the file, as shown below.Ģ. $show = file_get_contents($data) // here $data is called for fetching the files message $data = './files/myfile.txt' // it is the path of the text files Tests.php load->helper('files') // loading the files helper You can develop a web applicationĮxample: Create a Tests.php file in application/controller In the files, we have written the following text.įriends, Welcome to the tutorial and example. In this folder createĪ file and write some text into it that can display on the local server.Ĭreated a file named myfile.txt file in the CodeIgniter-3.1.11/Filesįolder. Syntax $data = file_get_contents('./filepath/’) įunction, you should create a folder named Files. Syntax $this->load->helper(‘file’) The function of File HelpersĬontents of a files from the server that is stored in the root folder. Helper, you must load the helper in the controller's files. Is used to perform various tasks with files such as accessing files, writingĭata to files, deleting files, and more.
0 Comments
Leave a Reply. |