homer.favenir Posted October 12, 2009 Share Posted October 12, 2009 hi, i know how to unzip a zip file in php, but is there a way to just extract a certain file only? tia Quote Link to comment Share on other sites More sharing options...
gizmola Posted October 12, 2009 Share Posted October 12, 2009 Did you take a look at http://us.php.net/manual/en/function.ziparchive-extractto.php Quote Link to comment Share on other sites More sharing options...
homer.favenir Posted October 12, 2009 Author Share Posted October 12, 2009 i cant find where my file go... $file = "AG3421226.WDB09.02.010.pdf"; $zip = new ZipArchive; $res = $zip->open('\\\\asecasiagsd\\AGS\\AGS\\WIP\\PROOF_QA_CSR\\AG3421226.WDB09.02.010.zip'); if ($res === TRUE) { $zip->extractTo('\\\\asecasiagsd\\AGS\\AGS\\WIP\\PROOF_QA_CSR\\extract', $file); $zip->close(); echo 'ok'; } else { echo 'failed'; } Quote Link to comment Share on other sites More sharing options...
xsist10 Posted October 12, 2009 Share Posted October 12, 2009 The example on this page should help you. http://us.php.net/manual/en/function.ziparchive-getstream.php Quote Link to comment Share on other sites More sharing options...
gizmola Posted October 12, 2009 Share Posted October 12, 2009 Everything looks ok -- however, I'm wondering if these routines work ok with the windows file share? Can you try mapping a drive on the server and specifying the drive letter instead? It also might be a permissions or path issue. Are you using IIS or Apache? Can you create a simple file in that same directory using fopen() fwrite() fclose(), and see if that works ok? Quote Link to comment Share on other sites More sharing options...
homer.favenir Posted October 13, 2009 Author Share Posted October 13, 2009 i already make it work for just decompressing a whole zip file. so there is no problem in permission or path. or even in server apache or IIS. Quote Link to comment Share on other sites More sharing options...
gizmola Posted October 13, 2009 Share Posted October 13, 2009 Personally, windows is suppossed to accept either \ or / as path seperators. Just to remove any confusion I would only use the slash, so you don't have to be concerned about the escape property. With that said, if the code is not returning any error conditions, then my only suggestion is that the extracto path requires the ending slash. My suggestion would be to change your code so that it only uses the slash characters: so the extracTo method call would be: $zip->extractTo('//asecasiagsd/AGS/AGS/WIP/PROOF_QA_CSR/extract/', $file); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.