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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.