Introduction to the CI Framework's ability to recursively generate file paths and regenerate pictures

Source: Internet
Author: User
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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.