lupus2203 Posted March 26, 2013 Share Posted March 26, 2013 How to unzip files on remote server using PHP script.I tried to like this: $zip = new ZipArchive;$res = $zip->open('http://madm.dfki.de/demo/ip-countryside/ip2country.zip');if ($res === TRUE) { $zip->extractTo($_SERVER['DOCUMENT_ROOT'].'/app/webroot/ip2country/'); $zip->close(); echo 'ok';} else { echo 'failed, code:' . $res;}but, it does not work. This error occurs:Unable to access http://madm.dfki.de/demo/ip-countryside/ip2country.zipHow to solve this problem? Quote Link to comment https://forums.phpfreaks.com/topic/276177-how-to-unzip-files-on-remote-server-using-php-script/ Share on other sites More sharing options...
fesan Posted March 26, 2013 Share Posted March 26, 2013 (edited) Try setting the file permission to 744 in your script. http://php.net/manual/en/function.chmod.php change it back to 644 or whatever your correct mode is after executing the zip. Edited March 26, 2013 by fesan Quote Link to comment https://forums.phpfreaks.com/topic/276177-how-to-unzip-files-on-remote-server-using-php-script/#findComment-1421181 Share on other sites More sharing options...
exeTrix Posted March 26, 2013 Share Posted March 26, 2013 (edited) I don't think it's relating to permissions because I can download the file, so we can assume the issue isn't permission related. As far as I can tell the open method requires a file that's relative to the filesystem. Basically, I don't think it allows you to open files via HTTP, FTP or HTTPS protocols because the class doesn't extend SPLFileObject. I'd suggest trying to store the zip on the server using fopen (http://php.net/manual/en/function.fopen.php) then opening the ZipArchive and clear the tmp file in __destruct method. Edited March 26, 2013 by exeTrix Quote Link to comment https://forums.phpfreaks.com/topic/276177-how-to-unzip-files-on-remote-server-using-php-script/#findComment-1421191 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.