tags:

views:

43

answers:

2

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.  
}
A: 

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

GameBit
No you can't. You an do that if you extract the file(s). pathinfo expects the $filename to be a file physically present on the disk.
codaddict
yes we cannot check whether those are files or folders using php functions like is_dir or is_file or pathinfo. As these file does not have physical path.
Kamlesh Bhure
+2  A: 

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.

Kamlesh Bhure
That's indeed the way.
outis