jquery ajax的get传值遍历文件夹下的文件和文件夹 views视图层 <?php
namespace frontend\controllers;
use Yii;
use yii\web\Controller;
class BianController extends Controller
{
public function actionIndex()
{
return $this->render('index');
}
public function actionGet_fil(){
$path=$_GET['path'];
//print_r($path);die;
$handle = opendir($path);
while($file = readdir($handle)){
if($file=="."||$file=="..") continue;
$newFilePath = $path.DIRECTORY_SEPARATOR.$file;
if(is_dir($newFilePath)){
echo
"文件夹: ".$newFilePath."
";
// showDirectoryFile($newFilePath);
}
if(is_file($newFilePath)) echo
"文件:
".$newFilePath."
";
}
closedir($handle);
}
}
?>
controller控制器层 <?php
namespace frontend\controllers;
use Yii;
use yii\web\Controller;
class BianController extends Controller
{
public function actionIndex()
{
return $this->render('index');
}
public function actionGet_fil(){
$path=$_GET['path'];
//print_r($path);die;
$handle = opendir($path);
while($file = readdir($handle)){
if($file=="."||$file=="..") continue;
$newFilePath = $path.DIRECTORY_SEPARATOR.$file;
if(is_dir($newFilePath)){
echo
"文件夹: ".$newFilePath."
";
// showDirectoryFile($newFilePath);
}
if(is_file($newFilePath)) echo
"文件:
".$newFilePath."
";
}
closedir($handle);
}
}
?>