doutuan6158 2019-01-11 18:09
浏览 60

使用scandir()根据传递的变量(PHP)查找目录中的目标文件夹

iam using this code to show me the documents in a default Folder path.

<?php
$307 = $_GET['307'];
$2949 = $_GET['2949'];

$folder = '//Server/folder/307_XY28/2949_XY_128';

$alldata = scandir($folder); 

foreach ($alldata as $data) {
    $datainfo = pathinfo($folder."/".$data); 
    $size = ceil(filesize($location."/".$data)/1024); 
    //1024 = kb | 1048576 = MB | 1073741824 = GB
    if ($data != "." && $data != ".."  && $data != "_notes") { 
    ?>
    <li><a href="<?php echo $datainfo['dirname']."/".$datainfo['basename'];?>"><?php echo $datainfo['filename']; ?></a> (<?php echo $datainfo['extension']; ?> | <?php echo $size ; ?>kb)</li>
<?php
    };
 };
?> 

Under the Path: //Server/folder/ are much more folders with other numbers and content.

What i want is that I can check the global folder: //Server/folder/ with the received number from the previous page eg.307 in the foldername (eg.307_XY28) if it was found than check the subfolder with the next number eg. 2949. If the folder eg.2949_XY_128' exist show me the documents inside how I have it now.

Thank you for the help

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
    • ¥20 西门子S7-Graph,S7-300,梯形图
    • ¥50 用易语言http 访问不了网页
    • ¥50 safari浏览器fetch提交数据后数据丢失问题
    • ¥15 matlab不知道怎么改,求解答!!
    • ¥15 永磁直线电机的电流环pi调不出来
    • ¥15 用stata实现聚类的代码
    • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
    • ¥20 docker里部署springboot项目,访问不到扬声器
    • ¥15 netty整合springboot之后自动重连失效