This article mainly introduces the CI framework to implement the recursive generation of file paths and regenerate the picture function, involving CodeIgniter framework custom picture controller class to implement file directory recursion and call image processing extension class for picture generation related operation skills, need friends can refer to the next
This article describes the CI framework implementation of recursive generation of file paths and the ability to regenerate pictures. Share to everyone for your reference, as follows:
<?php if (! defined (' BasePath ')) exit (' No Direct script access allowed '); set_time_limit (0); class Img_build extends Ci_ controller{private static $img _path = ' upload_old/'; private static $new _path = ' upload/'; function __construct () {parent::__construct (); /** * Gets information about the path that needs to be read * $map = array (* ' path name ' = = = Array (file 1, file 2, file 3) * */Public Function I Ndex () {$this->load->helper (' directory '); Read path information $map = Directory_map (self:: $img _path, FALSE, TRUE); echo "<pre>"; Print_r ($MAP); echo "</pre>"; if (!empty ($map) && Is_array ($map)) {$this->build_path ($map); }}/** * recursively generates the corresponding path * @param array $map */Private Function Build_path ($map = Array ()) {if (!file_exists (sel F:: $new _path)) {mkdir (self:: $new _path, 0777); } foreach ($map as $key = + $val) {$old _img_path = self:: $img _path; $old _tmp_path = self:: $img _path. $key. ' /'; $new _img_path = SELF:: $new _path; $new _tmp_path = self:: $new _path. $key. ' /'; if (Is_dir ($old _tmp_path)) {//echo $new _tmp_path; if (!file_exists ($new _tmp_path)) {mkdir ($new _tmp_path, 0777); } Self:: $img _path = $old _tmp_path; Self:: $new _path = $new _tmp_path; echo ' path: ' Self:: $img _path. "
The above is the whole content of this article, I hope that everyone's learning has helped, more relevant content please pay attention to topic.alibabacloud.com!