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 Link to comment https://forums.phpfreaks.com/topic/177387-extract-a-file-from-zip-file/ 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 Link to comment https://forums.phpfreaks.com/topic/177387-extract-a-file-from-zip-file/#findComment-935289 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'; } Link to comment https://forums.phpfreaks.com/topic/177387-extract-a-file-from-zip-file/#findComment-935297 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 Link to comment https://forums.phpfreaks.com/topic/177387-extract-a-file-from-zip-file/#findComment-935298 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? Link to comment https://forums.phpfreaks.com/topic/177387-extract-a-file-from-zip-file/#findComment-935628 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. Link to comment https://forums.phpfreaks.com/topic/177387-extract-a-file-from-zip-file/#findComment-935862 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); Link to comment https://forums.phpfreaks.com/topic/177387-extract-a-file-from-zip-file/#findComment-935880 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.