PHP Daemon Configuration config file, and form form upload file

Source: Internet
Author: User

One, configure config file

1 Gets an array of config.php files,

2 Get the value of form form submission

3 Save the Update config.php file with the following code:

1         $color=$_post[' Color '];2         $backtype=$_post[' Backtype '];3         4         $settings=include(dirname(__dir__). ' /config.php ');5         6         $settings[' Themescolor ']= (int)$color;7         $settings[' Themesbackground ']= (int)$backtype;8         9         //Open Output BuffersTen         Ob_start();  One  A         //returns the PHP code generated by the array -         Var_export($settings); -  the         //returns the contents of the internal buffer -         $arrStr=ob_get_contents(); -  -         //Delete the contents of the internal buffer and close the internal buffer +         Ob_end_clean(); -  +         $config= ' <?php '.Php_eol A. ' Return '.$arrStr.‘;‘; at  -         //writes a string to the configuration file.  -         file_put_contents(dirname(__dir__). ' /config.php ',$config);

The config.php file is as follows:

<?phpreturn Array (  ' themescolor ' = 3,  ' themesbackground ' = 3,);

Second, form upload file

The code is as follows:

      if((($_files["Path"] ["type"] = = "Image/gif") | | ($_files["Path"] ["type"] = = "Image/jpeg") | |                ($_files["Path"] ["type"] = = "Image/png")) && ($_files["Path"] ["Size"] < 500000))        {            if($_files["Path"] ["error"] > 0)            {                Echo"Return Code:".$_files["Path"] ["Error"] ; }            Else            {                if(!file_exists($PATHHD)){//determine if the Save directory exists                    mkdir($PATHHD, 0777,true);//Create a Save directory                }                                 $tool->deleteall ($PATHHD);//Clear the Head folder//move the uploaded file to a new location.                 Move_uploaded_file($_files["Path"] ["Tmp_name"],$PATHHD.‘ /‘.$_files["Path"] ["Name"]); }        }        Else{echo "Invalid file";
}

PHP Daemon Configuration config file, and form form upload file

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.