Jump to content

zip file help


gvp16

Recommended Posts

Hi, ive got some code that extracts files from a zip file and puts them into a folder, how can i get the filenames of the files being extracted??

 

heres what ive got :

 

$filename = $_FILES['file']['name'];  
    $source = $_FILES['file']['tmp_name'];  
    $type = $_FILES['file']['type'];   
    $name = explode('.', $filename);   
   $target = $_SESSION["folder"]."/files/images/".$r["name"];
    // Ensures that the correct file was chosen  
    $accepted_types = array('application/zip', 'application/x-zip-compressed', 'multipart/x-zip','application/s-compressed');  
  
    foreach($accepted_types as $mime_type) {  
        if($mime_type == $type) {  
            $okay = true;  
            break;  
        }   
    }  
        
  //Safari and Chrome don't register zip mime types. Something better could be used here.  
    $okay = strtolower($name[1]) == 'zip' ? true: false; 

    if(!$okay) { 
          die("Please choose a zip file, dummy!");        
    } 
     
    //mkdir($target); 
    $saved_file_location = $target . $filename; 
     
    if(move_uploaded_file($source, $saved_file_location)) { 
        openZip($saved_file_location); 
    } else { 
        die("There was a problem. Sorry!"); 
    } 
    }
}	

 

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/191903-zip-file-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.