2017-07-09 16 views
0

このコードはファイルを解凍して動作しています。 unzipした後、unzipフォルダ名の名前を取得する方法。 zipファイル名のように 'demo65856.zip'であり、解凍フォルダ名は 'demo'です。 ZIPARCHIVEを使用して手動から おかげ解凍後にフォルダ名の名前を取得

if(isset($_POST['submit'])){ 

WP_Filesystem(); 
$destination = wp_upload_dir(); 
$normal_path = $path_array; 
$filename = $result->theme_file_name; 
$link_filename = substr($filename, 0, -4); 
$destination_path = $destination['basedir'].'/theme/'; 
$demo_link = $destination['baseurl'].'/theme/'.$link_filename; 
$unzipfile = unzip_file($destination_path.$filename, $destination_path); 

    if ($unzipfile) { 
    echo '<h3> <a href="'.$demo_link.'">demo link has created</a></h3>'; 
    } else { 
     echo 'There was an error unzipping the file.';  
    } 
} 

答えて

0

は、...

<?php 
$zip = new ZipArchive; 
if ($zip->open($filename)) 
{ 
    for($i = 0; $i < $zip->numFiles; $i++) 
    { 
      echo 'Filename: ' . $zip->getNameIndex($i) . '<br />'; 
    } 
} 
else 
{ 
    echo 'Error reading zip-archive!'; 
} 
?> 

だから、基本レベルであり、あなただけのベースディレクトリやファイルのリストを有することができるファイルの数によって異なります。あなたはそれを試して、あなたが得るものを見る必要があります。

+0

コードを自分のコードに実装できますか? – fiyan

関連する問題