php - ZipArchive not opening file - Error Code: 19 -


im having issues code being able open zip file have uploaded , moved folder, zip file uploads fine , can open in zip program however, when attempt open ziparchive extract data errors.

    $path = "../"; // upload directory           $count = 0;      foreach ($_files['files']['name'] $f => $name) {             if(move_uploaded_file($_files["files"]["tmp_name"][$f], $path . $name))              $count++; // number of uploaded file     }      $kioskfile = $_files['files']['name'][0];     $kioskfile = explode(".", $kioskfile);     $kioskfile = $kioskfile[0];     $zipfile = "../" . $kioskfile . ".zip";           $zip = new ziparchive;     $res = $zip->open($zipfile);     if ($res === true) {         $zip->extractto("./");         $zip->close();     } else {         echo "error cannot open zip file - error code: ";     } 

when run code shows me error code 19

ziparchive::er_nozip - 19

this error im getting, file exists , if use zip_open, returns can open zip file.

any greatful

edit1 if upload zip file manually create (using zip program) upload works fine. if use ziparchive created zip file, instantly errors error 19.

edit2 have added check make sure file exists in right directory , put print of location also, both match, still same issue. error 19

    $path = "../"; // upload directory           $count = 0;      foreach ($_files['files']['name'] $f => $name) {             if(move_uploaded_file($_files["files"]["tmp_name"][$f], $path . $name))              $count++; // number of uploaded file     }      $kioskfile = $_files['files']['name'][0];     $kioskfile = explode(".", $kioskfile);     $kioskfile = $kioskfile[0];     $realpath = realpath("../");     $zipfile = $realpath . "\\" .  $kioskfile . ".zip";           if (file_exists($zipfile)) {         $extract = zip_extract($zipfile, "../");         if ($extract === true) {          } else {             echo "the file " . $zipfile . " cannot opened";           }     } else {         echo "the file " . $zipfile . " not exist";         die();     } 

update1 think ive narrowed down either bit of code, or download script use download .zip file system, if leave zip on system , use exact same bit of code works fine.

here download code, maybe ive missed on causing issue.

    $fileid = $_get['id'];     $backuploc = "backups/";     $sql = "select * backups id = '" . addslashes($fileid) .  "' limit 1";     $res = mysql_query($sql);     $row = mysql_fetch_array($res);      $backupfile = $row['backupfile'];     $zipfile = $backuploc . "/" . $backupfile . ".zip";     $zipsize = filesize($zipfile);      header('content-type: application/zip');     header('content-disposition: attachment; filename="' . basename($zipfile). '"');      ob_end_flush();     readfile($zipfile);     exit;     die(); 

open archive text or hex editor , make sure have 'pk' signature @ start of file. if have html before signature, suggest buffers not being cleaned or being flushed when should not be, meaning php ziparchive assume invalid archive.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -