<?php
// 执行文件下载
set_time_limit (24 * 60 * 60);
$destination_folder = '../includes/icloud/Plugin/';
$newfname = $destination_folder . iconv("UTF-8","GB2312",urldecode(basename($url)));
$file = fopen ('文件下载地址', "rb");
if ($file) {
$newf = fopen ('/down/文件命名.zip', "wb");
if ($newf)
while(!feof($file)) {
fwrite($newf, fread($file, 1024 * 8 ), 1024 * 8 );
}
}
if ($file) {
fclose($file);
}
if ($newf) {
fclose($newf);
echo "下载成功";
}else{
    echo "下载失败";
}

<?php
function insert($file,$database,$name,$root,$pwd)//
    {
        //将表导入数据库
        header("Content-type: text/html; charset=utf-8");
        $_sql = file_get_contents($file);//写自己的.sql文件
        $_arr = explode(';', $_sql);
        $_mysqli = new mysqli($name,$root,$pwd,$database);
//第一个参数为域名,第二个为用户名,第三个为密码,第四个为数据库名字
        if (mysqli_connect_errno()) 
        {
            exit('连接数据库出错');
        }
        else{
            //执行sql语句
            $_mysqli->query('set names utf8;'); //设置编码方式
            foreach ($_arr as $_value) {
                $_mysqli->query($_value.';');
            }
        }
        $_mysqli->close();
        $_mysqli = null;
    }
    insert("数据库文件","数据库名","数据库地址","数据库账号","数据库密码");

<?php
$zip = new ZipArchive;

if ($zip->open('文件名.zip') === TRUE) {
//中文文件名要使用ANSI编码的文件格式
  $zip->extractTo('../includes/icloud/Plugin/');//提取全部文件
  //$zip->extractTo('/my/destination/dir/', array('pear_item.gif', 'testfromfile.php'));
//提取部分文件
  $zip->close();
}

Last modification:February 3rd, 2020 at 08:46 am
如果觉得我的文章对你有用,请随意赞赏