博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PHP获取Linux当前目录下文件并实现下载功能
阅读量:6984 次
发布时间:2019-06-27

本文共 5047 字,大约阅读时间需要 16 分钟。

使用nginx转发过去给php

server{	listen 9099;	server_name 18.5.6.2;	location / {		proxy_http_version 1.1;		root /opt/zidian/crackPass;		index index.html index.htm index.php;	}	location ~* \.php$ {		root /opt/zidian/crackPass;		fastcgi_pass 127.0.0.1:9000;		fastcgi_index index.php;		fastcgi_param SCRIPT_FILENAME /opt/zidian/crackPass$fastcgi_script_name;		include fastcgi_params;	}}

server_name  公网ip

fastcgi_pass 127.0.0.1:9000   转发给php(使用netstat -tlnp | grep php看到php的端口是9000)

index.php

";header("Content-type: text/html; charset=utf-8");function getsize($size, $format = 'kb') { $p = 0; if ($format == 'kb') { $p = 1; } elseif ($format == 'mb') { $p = 2; } elseif ($format == 'gb') { $p = 3; } $size /= pow(1024, $p); return number_format($size, 3);}function read_all ($dir){ if(!is_dir($dir)) return false; $handle = opendir($dir); if($handle){ while(($fl = readdir($handle)) !== false){ $temp = iconv('utf-8','utf-8',$dir.DIRECTORY_SEPARATOR.$fl); if(is_dir($temp) && $fl!='.' && $fl != '..'){ #echo '目录:'.$temp.'
'; #read_all($temp); }else{ if($fl!='.' && $fl != '..'){ #echo $fl; #echo '文件:'.$temp.'
'; $cfiletime = filectime($fl); echo "文件:"; echo ""; echo "'$fl'"; echo ""; echo ""; $size = filesize($fl); $size = getsize($size, 'mb'); echo "容量:"; echo "$size.'M'"; echo ""; # echo "创建时间:"; # echo "" .date("Y-m-d H:i:s",$cfiletime); echo ""; echo "
"; } } } }}read_all('.');echo "
";echo "";echo "";echo "";#echo "";?>

index.php(2018-06-21)

";header("Content-type: text/html; charset=utf-8");echo "

";echo "夏天分享小知识";echo "

";ini_set('date.timezone','Asia/Shanghai');function getsize($size, $format = 'kb') { $p = 0; if ($format == 'kb') { $p = 1; } elseif ($format == 'mb') { $p = 2; } elseif ($format == 'gb') { $p = 3; } $size /= pow(1024, $p); return number_format($size, 3);}function read_all ($dir){ if(!is_dir($dir)) return false; $handle = opendir($dir); if($handle){ while(($fl = readdir($handle)) !== false){ $temp = iconv('utf-8','utf-8',$dir.DIRECTORY_SEPARATOR.$fl); if(is_dir($temp) && $fl!='.' && $fl != '..'){ #echo '目录:'.$temp.'
'; #read_all($temp); }else{ if($fl!='.' && $fl != '..'){ #echo $fl; #echo '文件:'.$temp.'
'; $cfiletime = filectime($fl); echo "
"; echo "
"; echo "
"; echo "
"; echo "
"; echo "文件:"; echo ""; echo "'$fl'"; echo ""; echo ""; $size = filesize($fl); $size = getsize($size, 'mb'); echo " "; echo "容量:"; echo "$size.'M'"; echo ""; echo " "; echo "修改时间:"; echo "" .date("Y-m-d H:i:s",$cfiletime); echo ""; echo "
"; echo "
"; } } } }}read_all('.');echo "
";echo "";echo "";echo "";echo " ";echo "";echo "";echo "";echo " ";echo "";echo "";echo "";echo " ";echo "";echo "";echo "";echo " ";echo "";echo "";echo "";#echo "";?>

返回(2018-06-21)

";header("Content-type: text/html; charset=utf-8");echo "

";echo "夏天分享小知识";echo "

";ini_set('date.timezone','Asia/Shanghai');function getsize($size, $format = 'kb') { $p = 0; if ($format == 'kb') { $p = 1; } elseif ($format == 'mb') { $p = 2; } elseif ($format == 'gb') { $p = 3; } $size /= pow(1024, $p); return number_format($size, 3);}function read_all ($dir){ if(!is_dir($dir)) return false; $handle = opendir($dir); if($handle){ while(($fl = readdir($handle)) !== false){ $temp = iconv('utf-8','utf-8',$dir.DIRECTORY_SEPARATOR.$fl); if(is_dir($temp) && $fl!='.' && $fl != '..'){ #echo '目录:'.$temp.'
'; #read_all($temp); }else{ if($fl!='.' && $fl != '..'){ #echo $fl; #echo '文件:'.$temp.'
'; $cfiletime = filectime($fl); $mfiletime = filemtime($fl); echo "
"; echo "
"; echo "
"; echo "
"; echo "
"; echo "文件:"; echo ""; echo "'$fl'"; echo ""; echo ""; $size = filesize($fl); $size = getsize($size, 'mb'); echo " "; echo "容量:"; echo "$size.'M'"; echo ""; echo " "; echo "修改时间:"; echo "".date("Y-m-d H:i:s",$cfiletime); echo ""; #echo "创建时间:".date("Y-m-d H:i:s",$cfiletime); #echo "修改时间:".date("Y-m-d H:i:s",$mfiletime); echo "
"; echo "
"; } } } }}read_all('.');echo "
";echo "";echo "";echo "";#echo "";?>

作用:点击链接实现下载文件

 

转载于:https://www.cnblogs.com/chenglee/p/9143399.html

你可能感兴趣的文章
linux下vi命令大全
查看>>
插入排序
查看>>
android 简易播放器实现
查看>>
职场人:跳槽规划三点注意不可忽略
查看>>
IP 协议简介
查看>>
PHP特级课视频教程_第十五集 MySQL基础操作(一)_李强强
查看>>
pthread_create
查看>>
通用dao设计
查看>>
jQuery Easy-ui 之data-options总结
查看>>
jquery程序自动寻找迷宫出路
查看>>
Android中的设计模式之观察者模式
查看>>
网站安装程序
查看>>
获取所有已打开窗体的集合/可是样式
查看>>
关于SpringMVC的HttpMediaTypeNotSupportedException异常解决
查看>>
idea内嵌jetty运行springmvc项目报ConversionFailedException
查看>>
troubleshooting 解决算子函数返回NULL导致问题
查看>>
PHP 学习笔记 - - - 简单方法的使用 (字符串与数字)
查看>>
个人对团队组织的一些实践
查看>>
Configuring jdbc-pool for high-concurrency
查看>>
《PHP和MySQL Web 开发》 第10章 使用Web数据库
查看>>