手抄报 安全手抄报 手抄报内容 手抄报图片 英语手抄报 清明节手抄报 节约用水手抄报

php怎么上传压缩包并解压到指定目录

时间:2024-10-14 01:10:51

1、新建html文件zip.html,胆咣骜岱编辑内容如下:<html> <head> <meta charset='utf-8'> 媪青怍牙<title>上传压缩包</title> </head> <body> <div> <form action="http://127.0.0.1/test45.php" method="post" enctype="multipart/form-data"> <input type="file" name="upload"/> <input type="submit"> </form> </div> </body></html>

php怎么上传压缩包并解压到指定目录

2、新建3个文件(a.txt,b.txt,c.txt),并添加要压缩文件包(abc.zip):

php怎么上传压缩包并解压到指定目录

3、新建后台php文件,编辑如下内容:<?phpvar_dump($_FILES);在浏览器上传下zip压缩包,查看效果如下:

php怎么上传压缩包并解压到指定目录
php怎么上传压缩包并解压到指定目录

4、修改php文件内容如下:<挢旗扦渌;?php$name = $_FILES['upload']['n锾攒揉敫ame'];$tmp_name = $_FILES['upload']['tmp_name'];$savePath = "/usr/local/httpd/htdocs/".$name;$res = move_uploaded_file($tmp_name,$savePath);$zip=newZipArchive;if($zip->open($savePath)===TRUE){$zip->extractTo('/usr/local/httpd/htdocs/');$zip->close();echo'ok';}else{echo'failed';}

php怎么上传压缩包并解压到指定目录

5、浏览器重新上传abc.zip压缩包,查看服务器对应目录是否有相关文件:

php怎么上传压缩包并解压到指定目录
php怎么上传压缩包并解压到指定目录
© 手抄报圈