开发者

How we can read zip file and get information of files or folders contains without unzipping in PHP?

What I actually wanted to do is read zip file and then if it does contain folder then refuse it with some message.

I want user should upload zip file with files only without any directory structure. So I want to read zip file contains and check file structure. I am trying with following code snippet.

$zip = zip_open('/path/to/zipfile'); 
while($zip_entry = zip_read($zip)){
       $filename = zip_entry_name($zip_entry);
       //@todo check whether file or folder.开发者_运维技巧  
}


I have sorted out. I am now checking filename as strings wherever I am getting string ending with "/" that am treating as directory else as file.


can't you parse path of $filename? something like $dirName = pathinfo($filename, PATHINFO_DIRNAME)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜