php - Creating Encrypted Zip in Codeigniter -


in codeigniter controller have following code zip backup file database. problem when extract zip file, instead of single file inside, there other folder path inside of it.

    $this->load->dbutil();     $this->load->helper('date');     $this->load->helper('file');      set_time_limit(0);      $prefs = array(     'format'        => 'txt',                       // gzip, zip, txt     'filename'      => 'backup.sql',              // file name - needed zip files     'add_drop'      => true,                        // whether add drop table statements backup file     'add_insert'    => true,                        // whether add insert data backup file     'newline'       => "\n"                         // newline character used in backup file     );       $backup = $this->dbutil->backup($prefs);       $file = fcpath.'gb_dump_backup/backup.txt';     $zip = fcpath.'gb_dump_backup/'.now().'backup';      write_file($file, $backup);      system('zip -p pass '.$zip.' '.$file .' '); 

i'm not sure why zip creates path folder inside zip too. mean instead of archiving backup.txt , backup application folder till backup.txt file. after extracting zip file below picture :

enter image description here

zip includes paths files in zip folder creates default. add -j flag junk paths , include file.

system('zip -j -p pass '.$zip.' '.$file .' '); 

check out man page zip more info.

$man zip ...    -p    --paths           include relative file paths part of names of files stored in ar-           chive.  default.  -j option junks paths , stores           names of files. 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -