整了个BYET分销拿来自用,这文件管理器是真的不好用,但是这玩意是免费的,拿来建个轻量的网盘、图床又刚好够用,怎么办呢?
我毕竟之前为了折腾网络验证,开始学习了PHP,有点PHP基础了,那就…….
用PHP来下载文件,再用PHP来解压
下面的代码有相当大一部分是我从CSDN上借(zhao)鉴(chao)来的,毕竟我PHP技术也就工地搬砖大叔那种水平
首先,在解压这份zip文件之前,需要把这个文件下载下来
我个人不太喜欢设置太多变量,所以就…..
file_put_contents("iruanpInstallTemp.zip",file_get_contents("把你要下载的文件URL放在这里"));
执行了这行代码之后就会出现一个zip文件,这是服务器下载下来的源码压缩包
接下来需要把这个文件解压出来
//照抄https://blog.csdn.net/luoluozlb/article/details/72853885
function unzip($fromName, $toName)
{
echo filesize($fromName);
if(!file_exists($fromName)){
return FALSE;
}
$zipArc = new ZipArchive();
if(!$zipArc->open($fromName)){
return FALSE;
}
if(!$zipArc->extractTo($toName)){
$zipArc->close();
return FALSE;
}
return $zipArc->close();
}
echo unzip("iruanpInstallTemp.zip", "dir");
于是文件就会全部被放进一个名为dir的目录
把这些文件全部移动出来就可以交给VistaPanel自带的文件管理器了(其实是因为我不会写:( )
<?php
function unzip($fromName, $toName)
{
echo filesize($fromName);
if(!file_exists($fromName)){
return FALSE;
}
$zipArc = new ZipArchive();
if(!$zipArc->open($fromName)){
return FALSE;
}
if(!$zipArc->extractTo($toName)){
$zipArc->close();
return FALSE;
}
return $zipArc->close();
}
file_put_contents("iruanpInstallTemp.zip",file_get_contents("记得在这里写上你的源代码压缩包下载地址"));
echo unzip("iruanpInstallTemp.zip", "dir");
echo '<br>Done!';
?>