I Need Some help for unzip_file, this code working fine but i want to add extracted files to wp media library, But i don't know how to get unzip files name and path one by one https://codex.wordpress.org/Function_Reference/unzip_file


If i where you i would read the folder where the zip a

$path    = '/path/to/extract';
$file    = '/path/to/zip.zip';
unzip_file( $file, $path );
$files = scandir($path);
$files = array_diff(scandir($path), array('.', '..')); // removes empty spots from the array

and then do what you want with the files. File names are in the $files array.

foreach ($files as $key => $file) {
    # code...

Did not test it but i think this should work :)

| improve this answer | |
  • It is not what i am looking for, i want to pass unzipped files to a code one by one, and extract files located in current upload directory. – Uttam sahu Sep 22 '17 at 18:37
  • It is not what i am looking for But its ok, i am happy with your replay. – Uttam sahu Sep 23 '17 at 4:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.