Zipping Issue: Last File is not zipping

Cel bloga:

Celem tego bloga jest udzielenie pomocy w rozwiązaniu problemu ostatni plik nie jest zipowany". Jeśli napotykasz ten sam problem, ten blog pomoże. Przykład – Jeśli są 4 pliki tekstowe, tylko 3 pliki są w formacie zip.

Powód tego

The

Rozwiązanie:

Musisz wymienić

$ zip = new ZipArchive (); // zip o 2 dni starsze pliki foreach (glob ($ katalog. '/*.txt') jako $ a_plik) {if (filemtime ($ a_plik) <time () - 172800) {// 2 dni starszy 172800 $ filename_array = explode ("/", $ a_file); $ key = sizeof ($ tablica_plików) - 1; $ filename = $ tablica_plików [$ key]; $ source_path = $ katalog. '/'; $ zip_file = $ ścieżka_źródłowa.str_replace ('. txt', '', $ nazwa pliku). ". zip"; if ($ zip-> open ($ zip_file, ZipArchive :: CREATE)! == TRUE) {exit („nie można otworzyć”. $ zip_file. "\ n"); } $ zip-> addFile ($ a_file, $ filename); }} $ zip-> close (); // Zamieniono zip_close ($ zip) na $ zip-> close (); // Przenieś 90 lat starsze do Archiwum i usuń pliki starsze niż 180 dni foreach (glob ($ katalog. '/ *. Zip') jako $ a_file) {// usuń pliki starsze niż 180 dni. if (filemtime ($ a_file) <time () - 15552000) {// 180 dni starszy 15552000 unlink ($ a_file); }}

Podsumowanie

W tym blogu zmieniliśmy funkcję zamykania zipowania, aby naprawić dany problem.


Shivam Verma

Shivam Verma

Shivam Verma is an experienced software engineer in PHP development and Database design. His area of interest is website development. He likes to be aware of his surroundings and to learn new things by observing others. He believes that by doing this we can learn new things and can also enhance our knowledge everyday. He has started writing technical blogs with a view to help others in studying and learning new things in an easy way.

Leave a Reply

Your email address will not be published. Required fields are marked *