您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

web下载网站代码

2024/3/18 21:42:31发布49次查看
1.打包代码,并直接通过浏览器下载 2.解压zip文件到服务器 php ?php/** * @author markzhao(zhaody901#126.com) */$dir = dirname(__file__).'/';// zip and download// zip.php?type=zipdir=subdir// unzip deflate way zipped zip file// zip.php?type=unzip
1. 打包代码, 并直接通过浏览器下载
2. 解压zip文件到服务器
php open($name, ziparchive::create) === true) { $files = map($dir.$subdir); foreach ($files as $file) { $dir = str_replace('\\', '/', $dir); $file = str_replace('\\', '/', $file); $zip->addfile($file, '_root_/' . str_replace($dir, '', $file)); } $zip->close(); down($dir.$name); echo 'ok'; } else { echo 'failed'; }} else if ($type=='unzip') { $zip = new ziparchive(); if ($zip->open($name) === true) { $zip->extractto(dirname(__file__).'/'); $zip->close(); echo 'ok'; } else { echo 'failed'; }}function map($directory) { $files = array(); if (file_exists($directory) && is_dir($directory)) { foreach (new recursiveiteratoriterator(new recursivedirectoryiterator($directory)) as $file) { $files[] = $file->getrealpath(); } } return $files;}function down($file) { $filename = $filename ? $filename : basename($file); $filesize = filesize($file); ob_end_clean(); @set_time_limit(0); if (strpos($_server['http_user_agent'], 'msie') !== false) { header('cache-control: must-revalidate, post-check=0, pre-check=0'); header('pragma: public'); } else { header('pragma: no-cache'); } header('expires: ' . gmdate('d, d m y h:i:s') . ' gmt'); header('content-encoding: none'); header('content-length: ' . $filesize); header('content-disposition: attachment; filename=' . $filename); header('content-type: ' . $filetype); readfile($file); exit;}
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product